Skip to Content
Menu
This question has been flagged

I need to customize Global and Line Discounts (amount & percentage) into Sale / Purchase / Account.

I have done the Sale and Purchase parts. It is just adding fields and a few logics here and there and send the data to Account (account.move) by prepare_invoice methods.

Now here's the issue I am facing -- The Account. I am having a tremendous confusion of where I should modify. After I tried to understand and tracked the flow of the standard invoicing/billing, I am at lost. There are too many functions/variables for me, who do not understand accounting, to try to get the whole idea out of it.

I did add the discount fields that I need. However, the standard calculation of price / taxes / credit / debit are messed up when I try to inherit some methods that I think I should modify. I ended up having incorrect taxes, unbalanced credit/debit, and incorrect total amount. I tried editing here and there (by inheriting of course. I can still rollback everything I did).

The point is that I need precise suggestions and/or directions of what functions/methods I should inherit just enough to make discount possible. I have 2 Line Discount fields (amount and percent) and 2 Global Discount (also amount and percent). The calculation between them is not the point of interest here. The only problem at this point is to integrate these fields (from SO, PO, and manually created) into the calculation of everything in Invoicing/Billing.

Here are the fields:

account.move

global_discount_amount = fields.Float(string='Global Discount Amount', compute=compute_global_discount_amount, store=True)
global_discount_percent = fields.Float(string='Global Discount Percent', compute=compute_global_discount_percent, store=True)

account.move.line

discount_line_amount = fields.Float(string='Disc. Line Amount', compute=compute_discount_line_amount, store=True)
discount_line_percent = fields.Float(string='Disc. Line %', compute=compute_discount_line_percent, store=True)

Right now, I am messing with some methods such as: (a few examples)

account.move

  • _recompute_tax_lines

account.move.line

  • create
  • _get_fields_onchange_balance_model
  • _get_price_total_and_subtotal_model
  • _onchange_price_subtotal

Most of the modifications are written by copying the whole method from standard into my new model (inherit that standard model) and edit some codes here -- Override the standard code from my understanding.


Avatar
Discard
Related Posts Replies Views Activity
1
Jun 24
1739
0
Jan 24
443
0
Oct 22
68
0
Oct 22
7
1
Jan 24
2714