3/3/2020 odoo/product.
py at 76c443eda331b75bf5dfa7ec22b8eb22e1084343 · odoo/odoo · GitHub
Dismiss
Join GitHub today
GitHub is home to over 40 million developers working together to
host and review code, manage projects, and build software together.
Sign up
Tree: 76c443eda3 Find file Copy path
odoo / addons / account / models / [Link]
tivisse [MIG] account: Migrate remaining old API chuncks of code
d6e1d41 on Aug 8, 2016
4 contributors
Raw Blame History
73 lines (63 sloc) 3.6 KB
1 # -*- coding: utf-8 -*-
2
3 from odoo import api, fields, models, _
4 from [Link] import UserError
5
6
7 class ProductCategory([Link]):
8 _inherit = "[Link]"
9
10 property_account_income_categ_id = fields.Many2one('[Link]', company_dependent=True,
11 string="Income Account", oldname="property_account_income_categ",
[Link] 1/3
3/3/2020 odoo/[Link] at 76c443eda331b75bf5dfa7ec22b8eb22e1084343 · odoo/odoo · GitHub
12 domain=[('deprecated', '=', False)],
13 help="This account will be used for invoices to value sales.")
14 property_account_expense_categ_id = fields.Many2one('[Link]', company_dependent=True,
15 string="Expense Account", oldname="property_account_expense_categ",
16 domain=[('deprecated', '=', False)],
17 help="This account will be used for invoices to value expenses.")
18
19 #----------------------------------------------------------
20 # Products
21 #----------------------------------------------------------
22 class ProductTemplate([Link]):
23 _inherit = "[Link]"
24
25 taxes_id = fields.Many2many('[Link]', 'product_taxes_rel', 'prod_id', 'tax_id', string='Customer Taxes',
26 domain=[('type_tax_use', '=', 'sale')])
27 supplier_taxes_id = fields.Many2many('[Link]', 'product_supplier_taxes_rel', 'prod_id', 'tax_id', string='Vendor Taxes
28 domain=[('type_tax_use', '=', 'purchase')])
29 property_account_income_id = fields.Many2one('[Link]', company_dependent=True,
30 string="Income Account", oldname="property_account_income",
31 domain=[('deprecated', '=', False)],
32 help="This account will be used for invoices instead of the default one to value sales for the current product.")
33 property_account_expense_id = fields.Many2one('[Link]', company_dependent=True,
34 string="Expense Account", oldname="property_account_expense",
35 domain=[('deprecated', '=', False)],
36 help="This account will be used for invoices instead of the default one to value expenses for the current product.")
37
38 @[Link]
39 def write(self, vals):
40 #TODO: really? i don't see the reason we'd need that constraint..
41 check = [Link] and 'uom_po_id' in vals
42 if check:
43 self._cr.execute("SELECT id, uom_po_id FROM product_template WHERE id IN %s", [tuple([Link])])
44 uoms = dict(self._cr.fetchall())
45 res = super(ProductTemplate, self).write(vals)
46 if check:
47 self._cr.execute("SELECT id, uom_po_id FROM product_template WHERE id IN %s", [tuple([Link])])
[Link] 2/3
3/3/2020 odoo/[Link] at 76c443eda331b75bf5dfa7ec22b8eb22e1084343 · odoo/odoo · GitHub
48 if dict(self._cr.fetchall()) != uoms:
49 products = [Link]['[Link]'].search([('product_tmpl_id', 'in', [Link])])
50 if [Link]['[Link]'].search_count([('product_id', 'in', [Link])]):
51 raise UserError(_('You can not change the unit of measure of a product that has been already used in an acc
52 return res
53
54 @[Link]
55 def _get_product_accounts(self):
56 return {
57 'income': self.property_account_income_id or self.categ_id.property_account_income_categ_id,
58 'expense': self.property_account_expense_id or self.categ_id.property_account_expense_categ_id
59 }
60
61 @[Link]
62 def _get_asset_accounts(self):
63 res = {}
64 res['stock_input'] = False
65 res['stock_output'] = False
66 return res
67
68 @[Link]
69 def get_product_accounts(self, fiscal_pos=None):
70 accounts = self._get_product_accounts()
71 if not fiscal_pos:
72 fiscal_pos = [Link]['[Link]']
73 return fiscal_pos.map_accounts(accounts)
[Link] 3/3