Skip to content

Commit

Permalink
Merge pull request #119 from tarunbhardwaj/fix_product_list_price
Browse files Browse the repository at this point in the history
Added product_variant as dependency
  • Loading branch information
prakashpp committed Jun 5, 2015
2 parents c4a20a7 + 1bd9d64 commit c6e57f4
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 11 deletions.
20 changes: 13 additions & 7 deletions product.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,12 +283,6 @@ def extract_product_values_from_data(cls, product_data):
return {
'name': product_data.get('name') or
('SKU: ' + product_data.get('sku')),
'list_price': Decimal(
product_data.get('special_price') or
product_data.get('price') or
0.00
),
'cost_price': Decimal(product_data.get('cost') or 0.00),
'default_uom': channel.default_uom.id,
'salable': True,
'sale_uom': channel.default_uom.id,
Expand Down Expand Up @@ -331,6 +325,12 @@ def create_using_magento_data(cls, product_data):
'products': [('create', [{
'description': product_data.get('description'),
'code': product_data['sku'],
'list_price': Decimal(
product_data.get('special_price') or
product_data.get('price') or
0.00
),
'cost_price': Decimal(product_data.get('cost') or 0.00),
'channel_listings': [('create', [{
'product_identifier': product_data['product_id'],
'channel': channel.id,
Expand Down Expand Up @@ -381,9 +381,15 @@ def update_from_magento_using_data(self, product_data):
product_data
)
product_template_values.update({
'products': [('write', map(int, self.products), {
'products': [('write', [self], {
'description': product_data.get('description'),
'code': product_data['sku'],
'list_price': Decimal(
product_data.get('special_price') or
product_data.get('price') or
0.00
),
'cost_price': Decimal(product_data.get('cost') or 0.00),
})]
})
Template.write([self.template], product_template_values)
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ def run(self):
]
MODULE2PREFIX = {
'sale_channel': 'openlabs',
'product_variant': 'openlabs',
}
for dep in info.get('depends', []):
if not re.match(r'(ir|res|webdav)(\W|$)', dep):
Expand Down
4 changes: 2 additions & 2 deletions tests/test_product.py
Original file line number Diff line number Diff line change
Expand Up @@ -475,14 +475,14 @@ def test_0110_export_catalog(self):
product_template, = ProductTemplate.create([
{
'name': 'Test product',
'list_price': Decimal('100'),
'cost_price': Decimal('1'),
'account_expense': self.get_account_by_kind('expense'),
'account_revenue': self.get_account_by_kind('revenue'),
'default_uom': uom.id,
'sale_uom': uom.id,
'products': [('create', [{
'code': 'code',
'list_price': Decimal('100'),
'cost_price': Decimal('1'),
'description': 'This is a product description',
}])]
}]
Expand Down
4 changes: 2 additions & 2 deletions tests/test_sale.py
Original file line number Diff line number Diff line change
Expand Up @@ -645,8 +645,6 @@ def test_0050_export_shipment(self):
product, = ProductTemplate.create([
{
'name': 'Shipping product',
'list_price': Decimal('100'),
'cost_price': Decimal('1'),
'type': 'service',
'account_expense': self.get_account_by_kind('expense'),
'account_revenue': self.get_account_by_kind('revenue'),
Expand All @@ -655,6 +653,8 @@ def test_0050_export_shipment(self):
'products': [('create', [{
'code': 'code',
'description': 'This is a product description',
'list_price': Decimal('100'),
'cost_price': Decimal('1'),
}])]
}]
)
Expand Down
1 change: 1 addition & 0 deletions tryton.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ depends:
product_price_list
production
sale_channel
product_variant
xml:
sale.xml
product.xml
Expand Down

0 comments on commit c6e57f4

Please sign in to comment.