Untitled

mail@pastecode.io avatar
unknown
plain_text
19 days ago
662 B
3
Indexable
Never
from odoo import models, fields, api

class AccountInherit(models.Model):
    _inherit = 'account.move'
    
    regionid = fields.Many2one('crm.region',string="Region",compute="compute_region")
    
    @api.depends('region_id')
    def compute_region(self):
        self.regionid=None
        for account in self:
            sale_milestone = self.env['sale.milestone'].search([
                ('project_id.name', '=', account.invoice_origin),
                ('name', '=', self.invoice_line_ids.project_milestone_id.name)
            ])
            
            for milestone in sale_milestone:
                self.regionid=milestone.project_id.region_id.id
Leave a Comment