Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ADD] osi_quote_downpayment: allows downpayments on quotes #971

Merged
merged 1 commit into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions osi_quote_downpayment/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
23 changes: 23 additions & 0 deletions osi_quote_downpayment/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Copyright (C) 2024, Open Source Integrators
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

{
"name": "OSI Quote Downpayment",
"version": "17.0.1.0.0",
"license": "AGPL-3",
"author": "Open Source Integrators",
"category": "Sales",
"maintainer": "Open Source Integrators",
"summary": "Allow downpayments on Quote",
"website": "https://github.com/ursais/osi-addons",
"depends": [
"sale",
"account",
],
"data": [
"views/sale_order_views.xml",
"wizards/sale_make_invoice_advance_views.xml",
],
"installable": True,
"maintainers": ["bodedra"],
}
1 change: 1 addition & 0 deletions osi_quote_downpayment/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import account_move
23 changes: 23 additions & 0 deletions osi_quote_downpayment/models/account_move.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Copyright (C) 2019 - 2021, Open Source Integrators
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import fields, models


class AccountMove(models.Model):
_inherit = "account.move"

#Prevents price of downpayment from being reset on draft sale orders
def action_post(self):
downpayment_lines = {}
for rec in records:
downpayment_lines[rec.id] = {}
for line in rec.invoice_line_ids:
if "Down payment" in line.name:
downpayment_lines[rec.id][line.id] = line.price_unit
res = super().action_post()
for rec in records:
for line in rec.invoice_line_ids:
if "Down payment" in line.name:
downpayment_lines[rec.id][line.id] = line.price_unit
return res
15 changes: 15 additions & 0 deletions osi_quote_downpayment/views/sale_order_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<odoo>

<record id="sale_order_form_view_inherit" model="ir.ui.view">
<field name="name">sale.order.form.view.inherit</field>
<field name="model">sale.order</field>
<field name="type">form</field>
<field name="inherit_id" ref="sale.view_order_form" />
<field name="arch" type="xml">
<xpath expr="//button[@id='create_invoice']" position="attributes">
<attribute name="invisible">invoice_status != 'to invoice' or state in ['draft', 'sent']</attibute>
</xpath>
</field>
</record>

</odoo>
16 changes: 16 additions & 0 deletions osi_quote_downpayment/wizards/sale_make_invoice_advance_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>

<record id="sale_make_invoice_advance_view_inherit" model="ir.ui.view">
<field name="name">sale.make.invoice.advance.view.inherit</field>
<field name="model">sale.advance.payment.inv</field>
<field name="type">form</field>
<field name="inherit_id" ref="sale.view_sale_advance_payment_inv" />
<field name="arch" type="xml">
<xpath expr="//field[@name='advance_payment_method']" position="after">
<field name="deduct_down_payments" invisible="advance_payment_method != 'delivered'"/>
</xpath>
</field>
</record>

</odoo>
Loading