Skip to content

Commit

Permalink
[MIG] account_payment_promissory_note: Migration to 15.0
Browse files Browse the repository at this point in the history
  • Loading branch information
cesar-tecnativa authored and CarlosRoca13 committed Nov 3, 2022
1 parent 685b5ca commit d2a1bff
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 21 deletions.
2 changes: 1 addition & 1 deletion account_payment_promissory_note/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

{
"name": "Account Payment Promissory Note",
"version": "13.0.1.1.1",
"version": "15.0.1.0.0",
"license": "AGPL-3",
"author": "Tecnativa," "Odoo Community Association (OCA)",
"category": "Invoicing Management",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ class AccountAbstractPayment(models.AbstractModel):
_name = "account.promissory.note.mixin"
_description = "Promissory Note Mixin"

promissory_note = fields.Boolean(
string="Promissory Note",
)
promissory_note = fields.Boolean()
date_due = fields.Date(
string="Due Date",
)
Expand Down
3 changes: 2 additions & 1 deletion account_payment_promissory_note/models/account_payment.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,10 @@ def _prepare_payment_moves(self):

@api.onchange("promissory_note")
def _onchange_promissory_note(self):
super()._onchange_promissory_note()
result = super()._onchange_promissory_note()
if not self.date_due and self.promissory_note:
invoices = self.invoice_ids
same_partner = len(invoices.mapped("partner_id")) == 1
if invoices and same_partner:
self.date_due = max(invoices.mapped("invoice_date_due"))
return result
1 change: 1 addition & 0 deletions account_payment_promissory_note/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
* Sergio Teruel
* Alexandre Díaz
* Carlos Roca
* César A. Sánchez
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@
class TestAccountPaymentPromissoryNote(TransactionCase):
def setUp(self):
super().setUp()
self.payment_method = self.env["account.payment.method"].create(
{"name": "Test_MTH", "code": "TST", "payment_type": "inbound"}
)
self.payment_method = self.env.ref("account.account_payment_method_manual_in")
self.company = self.env.ref("base.main_company")
partner = self.env.ref("base.partner_demo")
self.invoice_1 = self.env["account.move"].create(
Expand All @@ -20,7 +18,7 @@ def setUp(self):
"partner_id": partner.id,
"invoice_date": "2020-09-14",
"invoice_date_due": "2020-09-23",
"type": "out_invoice",
"move_type": "out_invoice",
"invoice_line_ids": [(0, 0, {"name": "Test", "price_unit": 20})],
}
)
Expand All @@ -31,15 +29,15 @@ def setUp(self):
"partner_id": partner.id,
"invoice_date": "2020-09-14",
"invoice_date_due": "2020-09-22",
"type": "out_invoice",
"move_type": "out_invoice",
"invoice_line_ids": [(0, 0, {"name": "Test", "price_unit": 20})],
}
)
self.invoice_2.action_post()
self.payment_1 = self.env["account.payment"].create(
{
"payment_type": "inbound",
"payment_method_id": self.payment_method.id,
"payment_method_line_id": self.payment_method.id,
"amount": 50.00,
"journal_id": self.env["account.journal"]
.search([("type", "=", "sale")], limit=1)
Expand All @@ -50,7 +48,7 @@ def setUp(self):
{
"invoice_ids": [(4, self.invoice_1.id), (4, self.invoice_2.id)],
"payment_type": "inbound",
"payment_method_id": self.payment_method.id,
"payment_method_line_id": self.payment_method.id,
"amount": 50.00,
"journal_id": self.env["account.journal"]
.search([("type", "=", "sale")], limit=1)
Expand Down Expand Up @@ -88,7 +86,7 @@ def test_3_due_date_propagation(self):
active_ids=[self.invoice_1.id, self.invoice_2.id],
)
)
wiz_form.payment_method_id = self.payment_method
wiz_form.payment_method_line_id = self.payment_method
wiz_form.promissory_note = True
wiz_form.group_payment = True
wiz_form.date_due = datetime.datetime.strptime("2020-09-23", "%Y-%m-%d").date()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
<odoo>
<record id="view_account_payment_form_multi" model="ir.ui.view">
<field name="model">account.payment.register</field>
<field name="inherit_id" ref="account.view_account_payment_form_multi" />
<field name="inherit_id" ref="account.view_account_payment_register_form" />
<field name="arch" type="xml">
<xpath expr="//field[@name='payment_date']" position="after">
<field name="payment_date" position="after">
<field name="promissory_note" />
<field
name="date_due"
Expand All @@ -16,7 +16,7 @@
>
Set date due to all payments or empty to select last date due of each partner invoices group
</span>
</xpath>
</field>
</field>
</record>
</odoo>
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,26 @@
<field name="model">account.payment</field>
<field name="inherit_id" ref="account.view_account_payment_form" />
<field name="arch" type="xml">
<xpath expr="//field[@name='payment_date']" position="after">
<field name="date" position="after">
<field name="promissory_note" />
<field
name="date_due"
attrs="{'invisible': [('promissory_note','=', False)]}"
/>
</xpath>
</field>
</field>
</record>
<record id="view_account_payment_search" model="ir.ui.view">
<field name="model">account.payment</field>
<field name="inherit_id" ref="account.view_account_payment_search" />
<field name="arch" type="xml">
<xpath expr="//filter[@name='state_sent']" position="after">
<filter name='state_sent' position="after">
<filter
name='promissory_note'
string="Promissory Note"
domain="[('promissory_note', '=', True)]"
/>
</xpath>
</filter>
</field>
</record>
</odoo>
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,11 @@ def get_payments_vals(self):

@api.onchange("promissory_note")
def _onchange_promissory_note(self):
super()._onchange_promissory_note()
result = super()._onchange_promissory_note()
if not self.date_due and self.promissory_note:
active_ids = self._context.get("active_ids")
invoices = self.env["account.move"].browse(active_ids)
same_partner = len(invoices.mapped("partner_id")) == 1
if invoices and self.group_payment and same_partner:
self.date_due = max(invoices.mapped("invoice_date_due"))
return result

0 comments on commit d2a1bff

Please sign in to comment.