|
| 1 | +# -*- coding: utf-8 -*- |
| 2 | +from odoo import fields, models, api |
| 3 | + |
| 4 | + |
| 5 | +class Company(models.Model): |
| 6 | + _inherit = 'res.company' |
| 7 | + |
| 8 | + property_stock_account_input_categ_id = fields.Many2one(readonly=True) |
| 9 | + property_stock_account_output_categ_id = fields.Many2one(readonly=True) |
| 10 | + property_stock_valuation_account_id = fields.Many2one(readonly=True) |
| 11 | + |
| 12 | + |
| 13 | +class CompanyProperty(models.TransientModel): |
| 14 | + _inherit = 'res.company.property' |
| 15 | + |
| 16 | + property_stock_account_input_categ_id = fields.Many2one( |
| 17 | + comodel_name='account.account', |
| 18 | + string="Input Account for Stock Valuation", |
| 19 | + compute='_compute_property_fields', |
| 20 | + readonly=False, store=False, |
| 21 | + ) |
| 22 | + property_stock_account_output_categ_id = fields.Many2one( |
| 23 | + comodel_name='account.account', |
| 24 | + string="Output Account for Stock Valuation", |
| 25 | + compute='_compute_property_fields', |
| 26 | + readonly=False, store=False, |
| 27 | + ) |
| 28 | + property_stock_valuation_account_id = fields.Many2one( |
| 29 | + comodel_name='account.account', |
| 30 | + string="Account Template for Stock Valuation", |
| 31 | + compute='_compute_property_fields', |
| 32 | + readonly=False, store=False, |
| 33 | + ) |
| 34 | + |
| 35 | + @api.one |
| 36 | + def get_property_fields(self, object, properties): |
| 37 | + super(CompanyProperty, self).get_property_fields(object, properties) |
| 38 | + self.property_stock_account_input_categ_id = \ |
| 39 | + self.get_property_value('property_stock_account_input_categ_id', |
| 40 | + object, properties) |
| 41 | + self.property_stock_account_output_categ_id = \ |
| 42 | + self.get_property_value('property_stock_account_output_categ_id', |
| 43 | + object, properties) |
| 44 | + self.property_stock_valuation_account_id = \ |
| 45 | + self.get_property_value('property_stock_valuation_account_id', |
| 46 | + object, properties) |
| 47 | + |
| 48 | + @api.multi |
| 49 | + def get_property_fields_list(self): |
| 50 | + res = super(CompanyProperty, self).get_property_fields_list() |
| 51 | + res.append('property_stock_account_input_categ_id') |
| 52 | + res.append('property_stock_account_output_categ_id') |
| 53 | + res.append('property_stock_valuation_account_id') |
| 54 | + return res |
| 55 | + |
| 56 | + @api.model |
| 57 | + def set_properties(self, object, properties=False): |
| 58 | + super(CompanyProperty, self).set_properties(object, properties) |
| 59 | + self.set_property(object, 'property_stock_account_input_categ_id', |
| 60 | + self.property_stock_account_input_categ_id.id, |
| 61 | + properties) |
| 62 | + self.set_property(object, 'property_stock_account_output_categ_id', |
| 63 | + self.property_stock_account_output_categ_id.id, |
| 64 | + properties) |
| 65 | + self.set_property(object, 'property_stock_valuation_account_id', |
| 66 | + self.property_stock_valuation_account_id.id, |
| 67 | + properties) |
0 commit comments