From c06c040ffd00c1b51fbeff84100155bee1d88925 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Sat, 25 Oct 2008 16:49:15 +0200 Subject: [PATCH] Move product stuff in account_product module --- __init__.py | 2 +- __tryton__.py | 2 +- product.py | 112 -------------------------------------------------- product.xml | 52 ----------------------- 4 files changed, 2 insertions(+), 166 deletions(-) delete mode 100644 product.py delete mode 100644 product.xml diff --git a/__init__.py b/__init__.py index 6372cc6771..d415f1deec 100644 --- a/__init__.py +++ b/__init__.py @@ -1,4 +1,4 @@ #This file is part of Tryton. The COPYRIGHT file at the top level of #this repository contains the full copyright notices and license terms. + from invoice import * -from product import * diff --git a/__tryton__.py b/__tryton__.py index 8c76a18d71..07a5cf8696 100644 --- a/__tryton__.py +++ b/__tryton__.py @@ -17,10 +17,10 @@ 'res', 'workflow', 'currency', + 'account_product', ], 'xml': [ 'invoice.xml', - 'product.xml', ], 'translation': [ 'fr_FR.csv', diff --git a/product.py b/product.py deleted file mode 100644 index e8f6056bc0..0000000000 --- a/product.py +++ /dev/null @@ -1,112 +0,0 @@ -#This file is part of Tryton. The COPYRIGHT file at the top level of -#this repository contains the full copyright notices and license terms. - -from trytond.osv import fields, OSV - - -class Category(OSV): - _name = 'product.category' - - account_expense = fields.Property(type='many2one', - relation='account.account', string='Account Expense', - group_name='Accounting Properties', view_load=True, - domain="[('kind', '=', 'expense'), ('company', '=', company)]", - states={ - 'invisible': "not company", - }) - account_revenue = fields.Property(type='many2one', - relation='account.account', string='Account Revenue', - group_name='Accounting Properties', view_load=True, - domain="[('kind', '=', 'revenue'), ('company', '=', company)]", - states={ - 'invisible': "not company", - }) - customer_taxes = fields.Many2Many('account.tax', - 'product_customer_taxes_rel', 'product', 'tax', - 'Customer Taxes', domain=[('parent', '=', False)]) - supplier_taxes = fields.Many2Many('account.tax', - 'product_supplier_taxes_rel', 'product', 'tax', - 'Supplier Taxes', domain=[('parent', '=', False)]) - -Category() - - -class Template(OSV): - _name = 'product.template' - - account_expense = fields.Property(type='many2one', - string='Account Expense', group_name='Accounting Properties', - view_load=True, relation='account.account', - domain="[('kind', '=', 'expense'), ('company', '=', company)]", - states={ - 'invisible': "not company", - }, help='This account will be used instead of the one defined ' \ - 'on the category.') - account_revenue = fields.Property(type='many2one', - string='Account Revenue', group_name='Accounting Properties', - view_load=True, relation='account.account', - domain="[('kind', '=', 'revenue'), ('company', '=', company)]", - states={ - 'invisible': "not company", - }, help='This account will be used instead of the one defined ' \ - 'on the category.') - account_expense_used = fields.Function('get_account', type='many2one', - relation='account.account', string='Account Expense Used') - account_revenue_used = fields.Function('get_account', type='many2one', - relation='account.account', string='Account Revenue Used') - taxes_category = fields.Boolean('Use Category\'s Taxes', help='Use the taxes ' \ - 'defined on the category') - customer_taxes = fields.Many2Many('account.tax', - 'product_customer_taxes_rel', 'product', 'tax', - 'Customer Taxes', domain=[('parent', '=', False)], states={ - 'invisible': "bool(taxes_category)", - }) - supplier_taxes = fields.Many2Many('account.tax', - 'product_supplier_taxes_rel', 'product', 'tax', - 'Supplier Taxes', domain=[('parent', '=', False)], states={ - 'invisible': "bool(taxes_category)", - }) - customer_taxes_used = fields.Function('get_taxes', type='many2many', - relation='account.tax', string='Customer Taxes Used') - supplier_taxes_used = fields.Function('get_taxes', type='many2many', - relation='account.tax', string='Customer Taxes Used') - - def __init__(self): - super(Template, self).__init__() - self._error_messages.update({ - 'missing_account': 'There is no account ' \ - 'expense/revenue define on the product ' \ - '%s (%d)', - }) - - def default_taxes_category(self, cursor, user, context=None): - return False - - def get_account(self, cursor, user, ids, name, arg, context=None): - account_obj = self.pool.get('account.account') - res = {} - name = name[:-5] - for product in self.browse(cursor, user, ids, context=context): - if product[name]: - res[product.id] = account_obj.name_get(cursor, user, - product[name].id, context=context)[0] - else: - if product.category[name]: - res[product.id] = account_obj.name_get(cursor, user, - product.category[name].id, context=context)[0] - else: - self.raise_user_error(cursor, 'missing_account', - (product.name, product.id), context=context) - return res - - def get_taxes(self, cursor, user, ids, name, arg, context=None): - res = {} - name = name[:-5] - for product in self.browse(cursor, user, ids, context=context): - if product.taxes_category: - res[product.id] = [x.id for x in product.category[name]] - else: - res[product.id] = [x.id for x in product[name]] - return res - -Template() diff --git a/product.xml b/product.xml deleted file mode 100644 index 1cc84b52eb..0000000000 --- a/product.xml +++ /dev/null @@ -1,52 +0,0 @@ - - - - - - - product.category - - - - - - - - - - - - - ]]> - - - - - product.product - - - - - - - - - ]]> - - - - -