Ir al contenido
Menú
Se marcó esta pregunta
1 Responder
2559 Vistas

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
Descartar
Mejor respuesta

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
Descartar
Autor

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

Publicaciones relacionadas Respuestas Vistas Actividad
1
sept 23
2666
2
sept 23
12875
1
oct 23
1464
2
mar 15
3778
1
may 25
898