Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[13.0] [MIG] sale_product_smart_button: Migrated the module in v13. #381

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions sale_product_smart_buttons/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

{
'name': 'Sale Product Smart Buttons',
'version': '12.0.0.0.1',
'version': '13.0.0.0.1',
'sequence': 1,
'author': 'Serpent Consulting Services Pvt. Ltd.',
'maintainer': 'Serpent Consulting Services Pvt. Ltd.',
Expand All @@ -20,7 +20,7 @@
'license': 'AGPL-3',
'depends': ['sale_management'],
'data': [
'views/product_view.xml',
'views/product_view.xml',
],
'installable': True,
'application': False,
Expand Down
10 changes: 6 additions & 4 deletions sale_product_smart_buttons/models/product.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,35 @@
class ProductTemplate(models.Model):
_inherit = 'product.template'

@api.multi
@api.depends('product_variant_ids.sales_amt')
def _sales_amt(self):
for product in self:
product.sales_amt = sum([p.sales_amt
for p in product.product_variant_ids])
for p in product.product_variant_ids])

sales_amt = fields.Float(compute='_sales_amt', string='Sales amt')


class ProductProduct(models.Model):
_inherit = 'product.product'

@api.multi
def _sales_amt(self):
res = {}
amt = 0.00
sales_amount = 0.0
domain = [
('order_id.state', 'in', ['sale', 'done']),
('product_id', 'in', self.ids),
]
order_lines = self.env['sale.order.line'].search(domain)

for line in order_lines:
amt += line.price_subtotal
res[line.product_id.id] = {'amt': amt}
for product in self:
if res:
product.sales_amt = res.get(product.id, 0).get('amt', 0)
sales_amount = res[product.id].get(
'amt', 0.0) if product.id in res else 0.0
self.sales_amt = sales_amount

sales_amt = fields.Float(compute='_sales_amt', string='# Sales amt')
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion sale_product_smart_buttons/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</div>
<div class="oe_span12">
<div class="oe_demo oe_picture oe_screenshot">
<img src="sales_smart_button.png">
<img src="icecream.png">
</div>
</div>
</div>
Expand Down
Binary file not shown.