Remove accounts from products
issue3805 review45111002
This commit is contained in:
1 parent
748a5c077b
commit
db33534e22
5 files changed
+46
-34
No files matched your search
-14
@@ -33,20 +33,6 @@ class Template:
|
||||
},
|
||||
depends=['active', 'salable'])
|
||||
|
||||
@classmethod
|
||||
def __setup__(cls):
|
||||
super(Template, cls).__setup__()
|
||||
required = ~Eval('account_category', False) & Eval('salable', False)
|
||||
if not cls.account_revenue.states.get('required'):
|
||||
cls.account_revenue.states['required'] = required
|
||||
else:
|
||||
cls.account_revenue.states['required'] = (
|
||||
cls.account_revenue.states['required'] | required)
|
||||
if 'account_category' not in cls.account_revenue.depends:
|
||||
cls.account_revenue.depends.append('account_category')
|
||||
if 'salable' not in cls.account_revenue.depends:
|
||||
cls.account_revenue.depends.append('salable')
|
||||
|
||||
@classmethod
|
||||
def __register__(cls, module_name):
|
||||
TableHandler = backend.get('TableHandler')
|
||||
|
||||
@@ -1409,11 +1409,8 @@ class SaleLine(sequence_ordered(), ModelSQL, ModelView):
|
||||
'product': self.product.rec_name,
|
||||
})
|
||||
else:
|
||||
for name in ['default_product_account_revenue',
|
||||
'default_category_account_revenue']:
|
||||
invoice_line.account = account_config.get_multivalue(name)
|
||||
if invoice_line.account:
|
||||
break
|
||||
invoice_line.account = account_config.get_multivalue(
|
||||
'default_category_account_revenue')
|
||||
if not invoice_line.account:
|
||||
self.raise_user_error('missing_default_account_revenue', {
|
||||
'sale': self.sale.rec_name,
|
||||
|
||||
+15
-5
@@ -60,6 +60,19 @@ Create parties::
|
||||
>>> customer = Party(name='Customer')
|
||||
>>> customer.save()
|
||||
|
||||
Create account categories::
|
||||
|
||||
>>> ProductCategory = Model.get('product.category')
|
||||
>>> account_category = ProductCategory(name="Account Category")
|
||||
>>> account_category.accounting = True
|
||||
>>> account_category.account_expense = expense
|
||||
>>> account_category.account_revenue = revenue
|
||||
>>> account_category.save()
|
||||
|
||||
>>> account_category_tax, = account_category.duplicate()
|
||||
>>> account_category_tax.customer_taxes.append(tax)
|
||||
>>> account_category_tax.save()
|
||||
|
||||
Create product::
|
||||
|
||||
>>> ProductUom = Model.get('product.uom')
|
||||
@@ -73,9 +86,7 @@ Create product::
|
||||
>>> template.purchasable = True
|
||||
>>> template.salable = True
|
||||
>>> template.list_price = Decimal('10')
|
||||
>>> template.account_expense = expense
|
||||
>>> template.account_revenue = revenue
|
||||
>>> template.customer_taxes.append(tax)
|
||||
>>> template.account_category = account_category_tax
|
||||
>>> template.save()
|
||||
>>> product, = template.products
|
||||
|
||||
@@ -85,8 +96,7 @@ Create product::
|
||||
>>> template.type = 'service'
|
||||
>>> template.salable = True
|
||||
>>> template.list_price = Decimal('30')
|
||||
>>> template.account_expense = expense
|
||||
>>> template.account_revenue = revenue
|
||||
>>> template.account_category = account_category
|
||||
>>> template.save()
|
||||
>>> service, = template.products
|
||||
|
||||
|
||||
@@ -38,6 +38,15 @@ Create tax and tax rule::
|
||||
>>> no_tax.origin_tax = tax
|
||||
>>> foreign.save()
|
||||
|
||||
Create account categories::
|
||||
|
||||
>>> ProductCategory = Model.get('product.category')
|
||||
>>> account_category = ProductCategory(name="Account Category")
|
||||
>>> account_category.accounting = True
|
||||
>>> account_category.account_revenue = revenue
|
||||
>>> account_category.customer_taxes.append(tax)
|
||||
>>> account_category.save()
|
||||
|
||||
Create product::
|
||||
|
||||
>>> ProductUom = Model.get('product.uom')
|
||||
@@ -50,8 +59,7 @@ Create product::
|
||||
>>> template.type = 'goods'
|
||||
>>> template.salable = True
|
||||
>>> template.list_price = Decimal('10')
|
||||
>>> template.account_revenue = revenue
|
||||
>>> template.customer_taxes.append(tax)
|
||||
>>> template.account_category = account_category
|
||||
>>> template.save()
|
||||
>>> product, = template.products
|
||||
|
||||
|
||||
@@ -65,12 +65,19 @@ Create parties::
|
||||
>>> address.subdivision = new_york
|
||||
>>> customer2.save()
|
||||
|
||||
Create account categories::
|
||||
|
||||
>>> Category = Model.get('product.category')
|
||||
>>> account_category = Category(name="Account Category")
|
||||
>>> account_category.accounting = True
|
||||
>>> account_category.account_revenue = revenue
|
||||
>>> account_category.save()
|
||||
|
||||
Create products::
|
||||
|
||||
>>> ProductUom = Model.get('product.uom')
|
||||
>>> unit, = ProductUom.find([('name', '=', 'Unit')])
|
||||
>>> ProductTemplate = Model.get('product.template')
|
||||
>>> Category = Model.get('product.category')
|
||||
|
||||
>>> template1 = ProductTemplate()
|
||||
>>> template1.name = "Product1"
|
||||
@@ -78,7 +85,7 @@ Create products::
|
||||
>>> template1.type = 'service'
|
||||
>>> template1.salable = True
|
||||
>>> template1.list_price = Decimal('10')
|
||||
>>> template1.account_revenue = revenue
|
||||
>>> template1.account_category = account_category
|
||||
>>> template1.save()
|
||||
>>> product1, = template1.products
|
||||
|
||||
@@ -186,15 +193,16 @@ Check sale reporting per categories::
|
||||
... time_series = CategoryTimeseries.find([])
|
||||
... tree = CategoryTree.find([])
|
||||
>>> len(reports)
|
||||
3
|
||||
4
|
||||
>>> with config.set_context(context=context):
|
||||
... sorted((r.category.id, r.number, r.revenue) for r in reports) == \
|
||||
... sorted([(category_child1.id, 2, Decimal('30')),
|
||||
... (category_root2.id, 2, Decimal('30')),
|
||||
... (category_child2.id, 1, Decimal('10'))])
|
||||
... (category_child2.id, 1, Decimal('10')),
|
||||
... (account_category.id, 2, Decimal('40'))])
|
||||
True
|
||||
>>> len(time_series)
|
||||
5
|
||||
7
|
||||
>>> with config.set_context(context=context):
|
||||
... sorted((r.category.id, str(r.date), r.number, r.revenue)
|
||||
... for r in time_series) == sorted(
|
||||
@@ -202,16 +210,19 @@ Check sale reporting per categories::
|
||||
... (category_root2.id, str(sale1.sale_date.replace(day=1)), 1, Decimal('20')),
|
||||
... (category_child2.id, str(sale1.sale_date.replace(day=1)), 1, Decimal('10')),
|
||||
... (category_child1.id, str(sale2.sale_date.replace(day=1)), 1, Decimal('10')),
|
||||
... (category_root2.id, str(sale2.sale_date.replace(day=1)), 1, Decimal('10'))])
|
||||
... (category_root2.id, str(sale2.sale_date.replace(day=1)), 1, Decimal('10')),
|
||||
... (account_category.id, str(sale1.sale_date.replace(day=1)), 1, Decimal('30')),
|
||||
... (account_category.id, str(sale2.sale_date.replace(day=1)), 1, Decimal('10'))])
|
||||
True
|
||||
>>> len(tree)
|
||||
4
|
||||
5
|
||||
>>> with config.set_context(context=context):
|
||||
... sorted((r.name, r.revenue) for r in tree) == sorted([
|
||||
... (u'Root1', Decimal('40')),
|
||||
... (u'Child1', Decimal('30')),
|
||||
... (u'Child2', Decimal('10')),
|
||||
... (u'Root2', Decimal('30'))])
|
||||
... (u'Root2', Decimal('30')),
|
||||
... (u'Account Category', Decimal('40'))])
|
||||
True
|
||||
|
||||
Check sale reporting per regions::
|
||||
|
||||
Reference in new issue
Block a user