Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
1 Odpovědět
2681 Zobrazení

Hi,

I wanto to create in res.partner field (like:partner_order_total_amount) for calculate partner's total amount of uninvoiced sales orders.


For example;

Azure Partner has two Sale Order. This orders confirmed, but not invoiced;

SO1234=1.500 USD

SO1235=2.000 USD


I want to see this total amount (3.500 USD) in res.partner form in partner_order_total_amount field.


How can i do it?


Why i need do it?


Odoo's default credit limit calculate only invoiced amunt.

I want to calculate partner's available credit limit with not invoiced sale orders.


Thanks.

Avatar
Zrušit
Nejlepší odpověď

Hi,

You can define a compute field inheriting the res.partner model with the following function,

class ResPartner(models.Model):
    _inherit = 'res.partner'

partner_order_total_amount = fields.Float(
string='Total Uninvoiced Sales Orders',
compute='_compute_order_total',
store=True
)

@api.depends('sale_order_ids.amount_total', 'sale_order_ids.invoice_status')
def _compute_order_total(self):
for partner in self:
total_amount = 0.0
for order in partner.sale_order_ids:
if order.invoice_status != 'invoiced' and order.state == 'sale':
total_amount += order.amount_total
partner.partner_order_total_amount = total_amount

Thanks

Avatar
Zrušit
Autor

Dear Sachin,
Thank you very much. It is perfect and working.

Related Posts Odpovědi Zobrazení Aktivita
1
zář 23
2757
2
zář 23
12998
1
říj 23
1530
2
bře 15
3864
1
kvě 25
1018