Skip to content

Commit

Permalink
Merge pull request #971 from ursais/cb-quote-downpayments
Browse files Browse the repository at this point in the history
[ADD] osi_quote_downpayment: allows downpayments on quotes
  • Loading branch information
cbeddies authored Nov 12, 2024
2 parents dfef9cc + 6ac9b14 commit e5a64c6
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 0 deletions.
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>

0 comments on commit e5a64c6

Please sign in to comment.