Skip to content

Commit

Permalink
Merge PR grap#136 into 12.0
Browse files Browse the repository at this point in the history
Signed-off-by legalsylvain
  • Loading branch information
github-grap-bot committed Apr 18, 2023
2 parents 111bcd9 + 7ff5428 commit c403bb0
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
18 changes: 17 additions & 1 deletion recurring_consignment/models/account_move_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
# @author: Sylvain LE GAL (https://twitter.com/legalsylvain)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from odoo import fields, models
from odoo import _, api, fields, models
from odoo.exceptions import UserError


class AccountMoveLine(models.Model):
Expand All @@ -16,3 +17,18 @@ class AccountMoveLine(models.Model):
)

consignment_commission = fields.Float(string="Consignment Commission Rate")

@api.constrains("consignment_invoice_id")
def _check_consignment_invoice_id(self):
for line in self.filtered(lambda x: x.consignment_invoice_id):
if line.account_id != line.consignment_invoice_id.account_id:
raise UserError(
_(
"You try to create a commission invoice for the account %s,"
" with lines with account %s."
)
% (
line.account_id.display_name,
line.consignment_invoice_id.account_id.display_name,
)
)
7 changes: 5 additions & 2 deletions recurring_consignment/views/view_account_invoice.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,11 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
<tree string="Lines" editable="bottom">
<field name="date" />
<field name="move_id" />
<field name="debit" />
<field name="credit" />
<field name="name" />
<field name="tax_line_id" />
<field name="tax_ids" widget="many2many_tags"/>
<field name="debit" sum="Debit"/>
<field name="credit" sum="Credit"/>
<field name="consignment_commission" />
</tree>
</field>
Expand Down
3 changes: 1 addition & 2 deletions recurring_consignment/wizards/invoice_commission_wizard.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,9 @@ def invoice_commission(self):
move_AccountMoveLine = self.env["account.move.line"]
AccountInvoice = self.env["account.invoice"]
invoice_ids = []
grouped_data = {}

for wizard_line in self.wizard_line_ids:

grouped_data = {}
if not wizard_line.move_line_qty:
continue

Expand Down

0 comments on commit c403bb0

Please sign in to comment.