Merge branch 'master-advance-pricelist' into 'master'
Sale Advance Pricelist See merge request flectra-hq/flectra!60
This commit is contained in:
commit
64ed79ecc2
@ -2,7 +2,7 @@
|
||||
# Part of flectra. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
{
|
||||
'name': 'Sale Advance Ecommerce Pricelist',
|
||||
'name': 'Sale Advance Pricelist',
|
||||
'version': '1.0.0',
|
||||
'category': 'Sale',
|
||||
'author': 'FlectraHQ',
|
||||
|
@ -4,10 +4,10 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Flectra Server 1.1\n"
|
||||
"Project-Id-Version: Flectra Server 1.2\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2018-04-12 05:50+0000\n"
|
||||
"PO-Revision-Date: 2018-04-12 05:50+0000\n"
|
||||
"POT-Creation-Date: 2018-05-14 05:17+0000\n"
|
||||
"PO-Revision-Date: 2018-05-14 05:17+0000\n"
|
||||
"Last-Translator: <>\n"
|
||||
"Language-Team: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
@ -52,13 +52,19 @@ msgstr "Advance Pricelist with All Matched Rule"
|
||||
msgid "Advanced"
|
||||
msgstr "Advanced"
|
||||
|
||||
#. module: sale_advance_pricelist
|
||||
#: code:addons/sale_advance_pricelist/models/price_rules.py:119
|
||||
#, python-format
|
||||
msgid "All Products"
|
||||
msgstr "All Products"
|
||||
|
||||
#. module: sale_advance_pricelist
|
||||
#: model:ir.model.fields,field_description:sale_advance_pricelist.field_cart_rule_amt_value
|
||||
msgid "Amount"
|
||||
msgstr "Amount"
|
||||
|
||||
#. module: sale_advance_pricelist
|
||||
#: model:ir.ui.view,arch_db:sale_advance_pricelist.product_pricelist_view_flectra
|
||||
#: model:ir.ui.view,arch_db:sale_advance_pricelist.product_pricelist_view_advance
|
||||
#: model:ir.ui.view,arch_db:sale_advance_pricelist.view_cart_rule_tree
|
||||
#: model:ir.ui.view,arch_db:sale_advance_pricelist.view_coupon_code_tree
|
||||
#: model:ir.ui.view,arch_db:sale_advance_pricelist.view_price_rule_tree
|
||||
@ -81,7 +87,7 @@ msgid "Apply Coupon"
|
||||
msgstr "Apply Coupon"
|
||||
|
||||
#. module: sale_advance_pricelist
|
||||
#: model:ir.ui.view,arch_db:sale_advance_pricelist.view_order_form_flectra
|
||||
#: model:ir.ui.view,arch_db:sale_advance_pricelist.view_order_form_advance
|
||||
msgid "Apply Coupon Code"
|
||||
msgstr "Apply Coupon Code"
|
||||
|
||||
@ -147,9 +153,16 @@ msgstr "Cart Discount"
|
||||
msgid "Cart Rule"
|
||||
msgstr "Cart Rule"
|
||||
|
||||
#. module: sale_advance_pricelist
|
||||
#. flectra-web
|
||||
#: code:addons/sale_advance_pricelist/static/src/xml/discount_details_view.xml:80
|
||||
#, python-format
|
||||
msgid "Cart Rule (-):"
|
||||
msgstr "Cart Rule (-):"
|
||||
|
||||
#. module: sale_advance_pricelist
|
||||
#: model:ir.model,name:sale_advance_pricelist.model_cart_rule
|
||||
#: model:ir.ui.view,arch_db:sale_advance_pricelist.product_pricelist_view_flectra
|
||||
#: model:ir.ui.view,arch_db:sale_advance_pricelist.product_pricelist_view_advance
|
||||
#: model:ir.ui.view,arch_db:sale_advance_pricelist.view_cart_rule_tree
|
||||
msgid "Cart Rules"
|
||||
msgstr "Cart Rules"
|
||||
@ -175,6 +188,12 @@ msgstr "Categories"
|
||||
msgid "Category"
|
||||
msgstr "Category"
|
||||
|
||||
#. module: sale_advance_pricelist
|
||||
#: code:addons/sale_advance_pricelist/models/price_rules.py:112
|
||||
#, python-format
|
||||
msgid "Category: %s"
|
||||
msgstr "Category: %s"
|
||||
|
||||
#. module: sale_advance_pricelist
|
||||
#: model:ir.model.fields,field_description:sale_advance_pricelist.field_sale_order_coupon_flag
|
||||
msgid "Check Coupon Apply"
|
||||
@ -202,10 +221,17 @@ msgstr "Coupon"
|
||||
#. module: sale_advance_pricelist
|
||||
#: model:ir.model,name:sale_advance_pricelist.model_coupon_code
|
||||
#: model:ir.model.fields,field_description:sale_advance_pricelist.field_coupon_code_coupon_code
|
||||
#: model:ir.ui.view,arch_db:sale_advance_pricelist.product_pricelist_view_flectra
|
||||
#: model:ir.ui.view,arch_db:sale_advance_pricelist.product_pricelist_view_advance
|
||||
msgid "Coupon Code"
|
||||
msgstr "Coupon Code"
|
||||
|
||||
#. module: sale_advance_pricelist
|
||||
#. flectra-web
|
||||
#: code:addons/sale_advance_pricelist/static/src/xml/discount_details_view.xml:92
|
||||
#, python-format
|
||||
msgid "Coupon Code (-):"
|
||||
msgstr "Coupon Code (-):"
|
||||
|
||||
#. module: sale_advance_pricelist
|
||||
#: model:ir.model.fields,field_description:sale_advance_pricelist.field_product_pricelist_coupon_code_lines
|
||||
msgid "Coupon Code Items"
|
||||
@ -222,6 +248,37 @@ msgstr "Coupon Ref"
|
||||
msgid "Coupon Type"
|
||||
msgstr "Coupon Type"
|
||||
|
||||
#. module: sale_advance_pricelist
|
||||
#: code:addons/sale_advance_pricelist/models/sale.py:366
|
||||
#, python-format
|
||||
msgid "Coupon code (%s) Remaining Limit exceeds!"
|
||||
msgstr "Coupon code (%s) Remaining Limit exceeds!"
|
||||
|
||||
#. module: sale_advance_pricelist
|
||||
#: code:addons/sale_advance_pricelist/models/price_rules.py:388
|
||||
#, python-format
|
||||
msgid "Coupon code (%s) already exists!"
|
||||
msgstr "Coupon code (%s) already exists!"
|
||||
|
||||
#. module: sale_advance_pricelist
|
||||
#: code:addons/sale_advance_pricelist/models/sale.py:381
|
||||
#: code:addons/sale_advance_pricelist/models/sale.py:468
|
||||
#, python-format
|
||||
msgid "Coupon code (%s) condition criteria not match!"
|
||||
msgstr "Coupon code (%s) condition criteria not match!"
|
||||
|
||||
#. module: sale_advance_pricelist
|
||||
#: code:addons/sale_advance_pricelist/models/sale.py:362
|
||||
#, python-format
|
||||
msgid "Coupon code (%s) not found!"
|
||||
msgstr "Coupon code (%s) not found!"
|
||||
|
||||
#. module: sale_advance_pricelist
|
||||
#: code:addons/sale_advance_pricelist/models/sale.py:356
|
||||
#, python-format
|
||||
msgid "Coupon code does not apply to sale order pricelist!"
|
||||
msgstr "Coupon code does not apply to sale order pricelist!"
|
||||
|
||||
#. module: sale_advance_pricelist
|
||||
#: model:ir.model.fields,field_description:sale_advance_pricelist.field_cart_rule_create_uid
|
||||
#: model:ir.model.fields,field_description:sale_advance_pricelist.field_coupon_code_create_uid
|
||||
@ -244,6 +301,12 @@ msgstr "Created on"
|
||||
msgid "Description"
|
||||
msgstr "Description"
|
||||
|
||||
#. module: sale_advance_pricelist
|
||||
#: code:addons/sale_advance_pricelist/models/sale.py:147
|
||||
#, python-format
|
||||
msgid "Discount"
|
||||
msgstr "Discount"
|
||||
|
||||
#. module: sale_advance_pricelist
|
||||
#: model:ir.model.fields,field_description:sale_advance_pricelist.field_cart_rule_discount_percentage
|
||||
#: model:ir.model.fields,field_description:sale_advance_pricelist.field_sale_order_line_dummy_discount
|
||||
@ -266,6 +329,13 @@ msgstr "Discount Amount"
|
||||
msgid "Discount Amount Words"
|
||||
msgstr "Discount Amount Words"
|
||||
|
||||
#. module: sale_advance_pricelist
|
||||
#. flectra-web
|
||||
#: code:addons/sale_advance_pricelist/static/src/xml/discount_details_view.xml:27
|
||||
#, python-format
|
||||
msgid "Discount Amount to Words:"
|
||||
msgstr "Discount Amount to Words:"
|
||||
|
||||
#. module: sale_advance_pricelist
|
||||
#: model:ir.model.fields,field_description:sale_advance_pricelist.field_sale_order_discount_widget
|
||||
msgid "Discount Widget"
|
||||
@ -293,6 +363,12 @@ msgstr "Domain"
|
||||
msgid "End Date"
|
||||
msgstr "End Date"
|
||||
|
||||
#. module: sale_advance_pricelist
|
||||
#: code:addons/sale_advance_pricelist/models/price_rules.py:98
|
||||
#, python-format
|
||||
msgid "End Date date not valid in Product Rule Lines!"
|
||||
msgstr "End Date date not valid in Product Rule Lines!"
|
||||
|
||||
#. module: sale_advance_pricelist
|
||||
#: model:ir.model.fields,field_description:sale_advance_pricelist.field_coupon_code_extra_discount_percentage
|
||||
msgid "Extra Discount"
|
||||
@ -315,6 +391,13 @@ msgstr "Flat Discount"
|
||||
msgid "Global"
|
||||
msgstr "Global"
|
||||
|
||||
#. module: sale_advance_pricelist
|
||||
#. flectra-web
|
||||
#: code:addons/sale_advance_pricelist/static/src/xml/discount_details_view.xml:44
|
||||
#, python-format
|
||||
msgid "Gross Amount:"
|
||||
msgstr "Gross Amount:"
|
||||
|
||||
#. module: sale_advance_pricelist
|
||||
#: model:ir.model.fields,field_description:sale_advance_pricelist.field_sale_order_have_coupon_code
|
||||
msgid "Have Coupon Code"
|
||||
@ -428,7 +511,21 @@ msgid "Percent"
|
||||
msgstr "Percent"
|
||||
|
||||
#. module: sale_advance_pricelist
|
||||
#: model:ir.ui.view,arch_db:sale_advance_pricelist.product_pricelist_view_flectra
|
||||
#: code:addons/sale_advance_pricelist/models/price_rules.py:74
|
||||
#: code:addons/sale_advance_pricelist/models/price_rules.py:217
|
||||
#: code:addons/sale_advance_pricelist/models/price_rules.py:334
|
||||
#, python-format
|
||||
msgid "Percentage should be between 0% to 100%!"
|
||||
msgstr "Percentage should be between 0% to 100%!"
|
||||
|
||||
#. module: sale_advance_pricelist
|
||||
#: code:addons/sale_advance_pricelist/models/sale.py:351
|
||||
#, python-format
|
||||
msgid "Please enter the Coupon code!"
|
||||
msgstr "Please enter the Coupon code!"
|
||||
|
||||
#. module: sale_advance_pricelist
|
||||
#: model:ir.ui.view,arch_db:sale_advance_pricelist.product_pricelist_view_advance
|
||||
msgid "Price"
|
||||
msgstr "Price"
|
||||
|
||||
@ -438,10 +535,17 @@ msgstr "Price"
|
||||
msgid "Price Rule"
|
||||
msgstr "Price Rule"
|
||||
|
||||
#. module: sale_advance_pricelist
|
||||
#. flectra-web
|
||||
#: code:addons/sale_advance_pricelist/static/src/xml/discount_details_view.xml:68
|
||||
#, python-format
|
||||
msgid "Price Rule (-):"
|
||||
msgstr "Price Rule (-):"
|
||||
|
||||
#. module: sale_advance_pricelist
|
||||
#: model:ir.model,name:sale_advance_pricelist.model_price_rule
|
||||
#: model:ir.model.fields,field_description:sale_advance_pricelist.field_product_pricelist_rule_ids
|
||||
#: model:ir.ui.view,arch_db:sale_advance_pricelist.product_pricelist_view_flectra
|
||||
#: model:ir.ui.view,arch_db:sale_advance_pricelist.product_pricelist_view_advance
|
||||
#: model:ir.ui.view,arch_db:sale_advance_pricelist.view_price_rule_tree
|
||||
msgid "Price Rules"
|
||||
msgstr "Price Rules"
|
||||
@ -456,7 +560,14 @@ msgid "Pricelist"
|
||||
msgstr "Pricelist"
|
||||
|
||||
#. module: sale_advance_pricelist
|
||||
#: model:ir.ui.view,arch_db:sale_advance_pricelist.product_pricelist_view_flectra
|
||||
#. flectra-web
|
||||
#: code:addons/sale_advance_pricelist/static/src/xml/discount_details_view.xml:56
|
||||
#, python-format
|
||||
msgid "Pricelist (-):"
|
||||
msgstr "Pricelist (-):"
|
||||
|
||||
#. module: sale_advance_pricelist
|
||||
#: model:ir.ui.view,arch_db:sale_advance_pricelist.product_pricelist_view_advance
|
||||
msgid "Pricelist Items"
|
||||
msgstr "Pricelist Items"
|
||||
|
||||
@ -466,6 +577,7 @@ msgid "Pricelist Type"
|
||||
msgstr "Pricelist Type"
|
||||
|
||||
#. module: sale_advance_pricelist
|
||||
#: model:ir.model,name:sale_advance_pricelist.model_product_product
|
||||
#: model:ir.model.fields,field_description:sale_advance_pricelist.field_cart_rule_product_id
|
||||
#: model:ir.model.fields,field_description:sale_advance_pricelist.field_coupon_code_product_id
|
||||
#: model:ir.model.fields,field_description:sale_advance_pricelist.field_price_rule_product_id
|
||||
@ -521,7 +633,7 @@ msgid "Remaining Usage Limit"
|
||||
msgstr "Remaining Usage Limit"
|
||||
|
||||
#. module: sale_advance_pricelist
|
||||
#: model:ir.ui.view,arch_db:sale_advance_pricelist.view_order_form_flectra
|
||||
#: model:ir.ui.view,arch_db:sale_advance_pricelist.view_order_form_advance
|
||||
msgid "Remove Coupon Code"
|
||||
msgstr "Remove Coupon Code"
|
||||
|
||||
@ -565,6 +677,12 @@ msgstr "Sequence"
|
||||
msgid "Start Date"
|
||||
msgstr "Start Date"
|
||||
|
||||
#. module: sale_advance_pricelist
|
||||
#: code:addons/sale_advance_pricelist/models/price_rules.py:92
|
||||
#, python-format
|
||||
msgid "Start Date date not valid in Product Rule Lines!"
|
||||
msgstr "Start Date date not valid in Product Rule Lines!"
|
||||
|
||||
#. module: sale_advance_pricelist
|
||||
#: selection:cart.rule,apply_on:0
|
||||
msgid "Subtotal At Least"
|
||||
@ -585,11 +703,36 @@ msgstr "Sum of Item Qty at least"
|
||||
msgid "Sum of Item Qty less than"
|
||||
msgstr "Sum of Item Qty less than"
|
||||
|
||||
#. module: sale_advance_pricelist
|
||||
#: code:addons/sale_advance_pricelist/models/sale.py:353
|
||||
#, python-format
|
||||
msgid "There is no sale order line!"
|
||||
msgstr "There is no sale order line!"
|
||||
|
||||
#. module: sale_advance_pricelist
|
||||
#: code:addons/sale_advance_pricelist/models/price_rules.py:356
|
||||
#, python-format
|
||||
msgid "Total Percentage ( Discount + Extra ) should be between 0% to 100%!"
|
||||
msgstr "Total Percentage ( Discount + Extra ) should be between 0% to 100%!"
|
||||
|
||||
#. module: sale_advance_pricelist
|
||||
#: model:ir.model.fields,field_description:sale_advance_pricelist.field_coupon_code_usage_limit
|
||||
msgid "Total Usage Limit"
|
||||
msgstr "Total Usage Limit"
|
||||
|
||||
#. module: sale_advance_pricelist
|
||||
#: code:addons/sale_advance_pricelist/models/sale.py:371
|
||||
#, python-format
|
||||
msgid "Untaxed Amount (%s) must be greater than Min Order Amount (%s) which required for the apply coupon code!"
|
||||
msgstr "Untaxed Amount (%s) must be greater than Min Order Amount (%s) which required for the apply coupon code!"
|
||||
|
||||
#. module: sale_advance_pricelist
|
||||
#. flectra-web
|
||||
#: code:addons/sale_advance_pricelist/static/src/xml/discount_details_view.xml:104
|
||||
#, python-format
|
||||
msgid "Untaxed Amount:"
|
||||
msgstr "Untaxed Amount:"
|
||||
|
||||
#. module: sale_advance_pricelist
|
||||
#: model:ir.model.fields,field_description:sale_advance_pricelist.field_coupon_code_code_valid_from
|
||||
msgid "Valid From"
|
||||
@ -600,6 +743,21 @@ msgstr "Valid From"
|
||||
msgid "Valid To"
|
||||
msgstr "Valid To"
|
||||
|
||||
#. module: sale_advance_pricelist
|
||||
#: code:addons/sale_advance_pricelist/models/price_rules.py:73
|
||||
#: code:addons/sale_advance_pricelist/models/price_rules.py:216
|
||||
#: code:addons/sale_advance_pricelist/models/price_rules.py:333
|
||||
#: code:addons/sale_advance_pricelist/models/price_rules.py:355
|
||||
#, python-format
|
||||
msgid "Warning"
|
||||
msgstr "Warning"
|
||||
|
||||
#. module: sale_advance_pricelist
|
||||
#: code:addons/sale_advance_pricelist/models/sale.py:636
|
||||
#, python-format
|
||||
msgid "You can not change order line. Please remove coupon code first!"
|
||||
msgstr "You can not change order line. Please remove coupon code first!"
|
||||
|
||||
#. module: sale_advance_pricelist
|
||||
#: model:ir.model,name:sale_advance_pricelist.model_rule_line
|
||||
msgid "rule.line"
|
||||
|
@ -334,6 +334,17 @@ class CouponCode(models.Model):
|
||||
'message': _("Percentage should be between 0% to 100%!")})
|
||||
self.discount_amount = 0.0
|
||||
return {'warning': warning}
|
||||
if self.coupon_type not in ['percent', 'fixed_amount',
|
||||
'buy_x_get_percent']:
|
||||
self.discount_amount = 0.0
|
||||
if self.coupon_type != 'clubbed':
|
||||
self.flat_discount = 0.0
|
||||
self.extra_discount_percentage = 0.0
|
||||
if self.coupon_type not in ['buy_x_get_y', 'buy_x_get_y_other',
|
||||
'buy_x_get_percent']:
|
||||
self.number_of_x_product = 0.0
|
||||
self.number_of_y_product = 0.0
|
||||
self.other_product_id = False
|
||||
|
||||
@api.onchange('flat_discount', 'extra_discount_percentage')
|
||||
def check_clubbed_percentage(self):
|
||||
@ -371,7 +382,8 @@ class CouponCode(models.Model):
|
||||
def check_duplicate_coupon_code(self):
|
||||
check_coupon_id = self.search([
|
||||
('coupon_code', '=', self.coupon_code),
|
||||
('id', '!=', self.id)])
|
||||
('id', '!=', self.id),
|
||||
('pricelist_id', '=', self.pricelist_id.id)])
|
||||
if check_coupon_id:
|
||||
raise Warning(_("Coupon code (%s) already exists!") % (
|
||||
self.coupon_code))
|
||||
|
@ -4,6 +4,7 @@
|
||||
from flectra import api, fields, models
|
||||
from flectra.exceptions import UserError
|
||||
from itertools import chain
|
||||
from flectra.tools import pycompat
|
||||
|
||||
|
||||
class Pricelist(models.Model):
|
||||
@ -30,17 +31,16 @@ class Pricelist(models.Model):
|
||||
'coupon.code', 'pricelist_id', 'Coupon Code Items',
|
||||
copy=True)
|
||||
|
||||
def get_product_price_rule_flectra(
|
||||
def get_product_price_rule_advance(
|
||||
self, product, quantity, partner,
|
||||
rule_id, price_unit, date=False, uom_id=False):
|
||||
date=False, uom_id=False):
|
||||
self.ensure_one()
|
||||
return self._compute_price_rule_flectra(
|
||||
return self._compute_price_rule_advance(
|
||||
[(product, quantity, partner)],
|
||||
rule_id, price_unit, date=date, uom_id=uom_id)[product.id]
|
||||
date=date, uom_id=uom_id)[product.id]
|
||||
|
||||
@api.multi
|
||||
def _compute_price_rule_flectra(self, products_qty_partner,
|
||||
rule_id, price_unit,
|
||||
def _compute_price_rule_advance(self, products_qty_partner,
|
||||
date=False, uom_id=False):
|
||||
self.ensure_one()
|
||||
if not date:
|
||||
@ -91,10 +91,9 @@ class Pricelist(models.Model):
|
||||
'AND (item.pricelist_id = %s) '
|
||||
'AND (item.start_date IS NULL OR item.start_date<=%s) '
|
||||
'AND (item.end_date IS NULL OR item.end_date>=%s)'
|
||||
'ORDER BY item.sequence,categ.parent_left desc',
|
||||
(prod_tmpl_ids, rule_id.ids, prod_ids,
|
||||
'ORDER BY item.sequence,item.id,categ.parent_left desc',
|
||||
(prod_tmpl_ids, self.rule_ids.ids, prod_ids,
|
||||
categ_ids, self.id, date, date))
|
||||
|
||||
item_ids = [x[0] for x in self._cr.fetchall()]
|
||||
items = self.env['rule.line'].browse(item_ids)
|
||||
results = {}
|
||||
@ -156,9 +155,12 @@ class Pricelist(models.Model):
|
||||
dis_price = 0.0
|
||||
if price is not False:
|
||||
if rule.rule_type == 'fixed_amount':
|
||||
if price != price_unit:
|
||||
price_unit = self._context.get('price_unit')
|
||||
if price_unit and price != price_unit \
|
||||
and self.discount_policy == 'without_discount':
|
||||
price = price_unit
|
||||
if price < rule.discount_amount:
|
||||
if price <= rule.discount_amount \
|
||||
and self.apply_method != 'smallest_discount':
|
||||
price = 0
|
||||
suitable_rule = rule
|
||||
break
|
||||
@ -177,6 +179,14 @@ class Pricelist(models.Model):
|
||||
min_dis_price.append(price - dis_price)
|
||||
else:
|
||||
max_dis_price.append(price - dis_price)
|
||||
|
||||
# Used context for add Cart Rules Discount
|
||||
cart_price = 0.0
|
||||
if self._context.get('order_id', False):
|
||||
order_id = self._context.get('order_id')
|
||||
cart_per = order_id.get_cart_rules_discount(
|
||||
order_id.get_values())
|
||||
cart_price = price * (cart_per / 100) or 0.0
|
||||
if one_dis_price > 0.0:
|
||||
price = one_dis_price
|
||||
elif all_dis_price > 0.0:
|
||||
@ -185,8 +195,65 @@ class Pricelist(models.Model):
|
||||
price = price - min(min_dis_price)
|
||||
elif max_dis_price:
|
||||
price = price - max(max_dis_price)
|
||||
if cart_price > 0.0:
|
||||
price -= cart_price
|
||||
price = product.currency_id.compute(
|
||||
price, self.currency_id, round=False)
|
||||
results[product.id] = (price,
|
||||
suitable_rule and suitable_rule.id or False)
|
||||
return results
|
||||
|
||||
# Used context for add Cart Rules Discount
|
||||
def get_products_price_advance(self, products, quantities,
|
||||
partners, date=False, uom_id=False):
|
||||
""" For a given pricelist, return price for products
|
||||
Returns: dict{product_id: product price}, in the given pricelist """
|
||||
self.ensure_one()
|
||||
vals = {
|
||||
product_id: res_tuple[0]
|
||||
for product_id, res_tuple in self._compute_price_rule_advance(
|
||||
list(pycompat.izip(products, quantities, partners)),
|
||||
date=date, uom_id=uom_id).items()
|
||||
}
|
||||
return vals
|
||||
|
||||
|
||||
class ProductProduct(models.Model):
|
||||
_inherit = "product.product"
|
||||
|
||||
# Overrides Function
|
||||
# Used context for add Cart Rules Discount
|
||||
def _compute_product_price(self):
|
||||
prices = {}
|
||||
pricelist_id_or_name = self._context.get('pricelist')
|
||||
if pricelist_id_or_name:
|
||||
pricelist = None
|
||||
partner = self._context.get('partner', False)
|
||||
quantity = self._context.get('quantity', 1.0)
|
||||
if isinstance(pricelist_id_or_name, pycompat.string_types):
|
||||
pricelist_name_search = \
|
||||
self.env['product.pricelist'].name_search(
|
||||
pricelist_id_or_name, operator='=', limit=1)
|
||||
if pricelist_name_search:
|
||||
pricelist = \
|
||||
self.env['product.pricelist'].browse(
|
||||
[pricelist_name_search[0][0]])
|
||||
elif isinstance(pricelist_id_or_name, pycompat.integer_types):
|
||||
pricelist = self.env['product.pricelist'].browse(
|
||||
pricelist_id_or_name)
|
||||
|
||||
if pricelist:
|
||||
quantities = [quantity] * len(self)
|
||||
partners = [partner] * len(self)
|
||||
if pricelist.pricelist_type == 'basic':
|
||||
prices = pricelist.get_products_price(
|
||||
self, quantities, partners)
|
||||
else:
|
||||
prices = pricelist.with_context(
|
||||
{'order_id': self._context.get('order_id')}
|
||||
).get_products_price_advance(
|
||||
self, quantities, partners)
|
||||
for product in self:
|
||||
product.price = prices.get(product.id, 0.0)
|
||||
if self._context.get('order_id', False):
|
||||
return product.price
|
||||
|
@ -25,19 +25,19 @@ class SaleOrder(models.Model):
|
||||
for order in self:
|
||||
if order.pricelist_id.pricelist_type == 'advance':
|
||||
order._update_all()
|
||||
cart_discount = 0.0
|
||||
cart_discount_per = \
|
||||
order.get_cart_rules_discount(order.get_values())
|
||||
if order.pricelist_id.discount_policy == 'without_discount':
|
||||
cart_discount = 0.0
|
||||
cart_discount_per = \
|
||||
order.get_cart_rules_discount(order.get_values())
|
||||
for line in order.order_line:
|
||||
if line.get_line_percentage(cart_discount_per) < 100:
|
||||
if line.get_line_percentage() < 100:
|
||||
cart_discount += \
|
||||
((line.price_unit * line.product_uom_qty
|
||||
) * cart_discount_per) / 100
|
||||
order.cart_discount = cart_discount
|
||||
else:
|
||||
for line in order.order_line:
|
||||
line.set_line_amount(cart_discount_per)
|
||||
line.set_line_amount()
|
||||
|
||||
@api.multi
|
||||
def get_cart_discount(self, cart_rule_id, values):
|
||||
@ -191,13 +191,23 @@ class SaleOrder(models.Model):
|
||||
coupon_discount_amount = 0.0
|
||||
total_price = (line.product_uom_qty * line.price_unit)
|
||||
if self.coupon_flag and not onchange_context and line.coupon_code_id:
|
||||
if line.dummy_discount:
|
||||
percent = line.dummy_discount - discount_per
|
||||
else:
|
||||
percent = line.discount - discount_per
|
||||
line.write({'check_coupon': False,
|
||||
'discount': line.discount - discount_per,
|
||||
'discount': percent,
|
||||
'coupon_code_id': False,
|
||||
'check_coupon': False})
|
||||
elif not cal_coupon and not remove:
|
||||
coupon_discount_amount = (total_price * discount_per) / 100
|
||||
line.discount = line.discount + discount_per
|
||||
percent = line.discount + discount_per
|
||||
if percent > 100:
|
||||
line.dummy_discount = percent
|
||||
line.discount = 100
|
||||
else:
|
||||
line.discount = percent
|
||||
line.dummy_discount = 0.0
|
||||
line.coupon_code_id = coupon_code_id.id
|
||||
line.check_coupon = True
|
||||
else:
|
||||
@ -306,17 +316,26 @@ class SaleOrder(models.Model):
|
||||
coupon_discount_amount = 0.0
|
||||
total_price = (line.product_uom_qty * line.price_unit)
|
||||
if self.coupon_flag and not onchange_context and line.coupon_code_id \
|
||||
and line.product_uom_qty > coupon_code_id.number_of_x_product:
|
||||
and line.product_uom_qty >= coupon_code_id.number_of_x_product:
|
||||
if line.dummy_discount:
|
||||
percent = line.dummy_discount - coupon_code_id.discount_amount
|
||||
else:
|
||||
percent = line.discount - coupon_code_id.discount_amount
|
||||
line.write({'check_coupon': False,
|
||||
'discount':
|
||||
line.discount - coupon_code_id.discount_amount,
|
||||
'discount': percent,
|
||||
'coupon_code_id': False,
|
||||
'check_coupon': False})
|
||||
elif not cal_coupon and not remove and line.product_uom_qty >= \
|
||||
coupon_code_id.number_of_x_product:
|
||||
coupon_discount_amount = \
|
||||
(total_price * coupon_code_id.discount_amount) / 100
|
||||
line.discount = line.discount + coupon_code_id.discount_amount
|
||||
percent = line.discount + coupon_code_id.discount_amount
|
||||
if percent > 100:
|
||||
line.dummy_discount = percent
|
||||
line.discount = 100
|
||||
else:
|
||||
line.discount = percent
|
||||
line.dummy_discount = 0.0
|
||||
line.coupon_code_id = coupon_code_id.id
|
||||
line.check_coupon = True
|
||||
else:
|
||||
@ -365,7 +384,12 @@ class SaleOrder(models.Model):
|
||||
|
||||
@api.multi
|
||||
def apply_coupon_code(self):
|
||||
coupon_id = self._check_Constraints()
|
||||
if self._context.get('website_id', False):
|
||||
coupon_obj = self.env['coupon.code']
|
||||
coupon_id = coupon_obj.get_coupon_records(
|
||||
self.have_coupon_code, self.pricelist_id)
|
||||
else:
|
||||
coupon_id = self._check_Constraints()
|
||||
order_line = self.order_line
|
||||
coupon_discount_amount = 0.0
|
||||
have_coupon_code = self.have_coupon_code
|
||||
@ -440,7 +464,7 @@ class SaleOrder(models.Model):
|
||||
line, coupon_id, onchange_context,
|
||||
cal_coupon, remove)
|
||||
check_coupon = False
|
||||
if check_coupon:
|
||||
if check_coupon and not self._context.get('website_id', False):
|
||||
raise Warning(_("Coupon code (%s) condition criteria not match!"
|
||||
) % (self.have_coupon_code))
|
||||
if qty:
|
||||
@ -463,9 +487,9 @@ class SaleOrderLine(models.Model):
|
||||
digits=dp.get_precision('Discount'), default=0.0)
|
||||
|
||||
@api.multi
|
||||
def get_line_percentage(self, percent):
|
||||
def get_line_percentage(self):
|
||||
self._onchange_discount()
|
||||
discount = self.discount + percent
|
||||
discount = self.discount
|
||||
if discount > 100:
|
||||
self.dummy_discount = discount
|
||||
discount = 100
|
||||
@ -473,17 +497,17 @@ class SaleOrderLine(models.Model):
|
||||
return discount
|
||||
|
||||
@api.multi
|
||||
def set_line_amount(self, percent):
|
||||
def set_line_amount(self):
|
||||
discount, product_price = self.get_rule_discount()
|
||||
if product_price:
|
||||
discount = product_price * (discount + percent) / 100
|
||||
discount = product_price * (discount) / 100
|
||||
self.price_unit = product_price - discount
|
||||
|
||||
@api.multi
|
||||
def get_total_coupon_code(self):
|
||||
return self.env['coupon.code'].get_coupon_discount(self, False)
|
||||
|
||||
def _get_real_price_currency_flectra(self, product, uom,
|
||||
def _get_real_price_currency_advance(self, product, uom,
|
||||
pricelist_id, price_unit):
|
||||
currency_id = pricelist_id.currency_id
|
||||
product_currency = \
|
||||
@ -514,20 +538,20 @@ class SaleOrderLine(models.Model):
|
||||
context_partner = dict(self.env.context,
|
||||
partner_id=self.order_id.partner_id.id,
|
||||
date=self.order_id.date_order)
|
||||
pricelist_context = dict(context_partner, uom=self.product_uom.id)
|
||||
pricelist_context = dict(context_partner, uom=self.product_uom.id,
|
||||
order_id=self.order_id,
|
||||
price_unit=self.price_unit)
|
||||
product_price = 0.0
|
||||
for rule in rules:
|
||||
adv_price, adv_rule_id = \
|
||||
self.order_id.pricelist_id.with_context(
|
||||
pricelist_context).get_product_price_rule_flectra(
|
||||
pricelist_context).get_product_price_rule_advance(
|
||||
self.product_id, self.product_uom_qty,
|
||||
self.order_id.partner_id, rule, self.price_unit)
|
||||
self.order_id.partner_id)
|
||||
rule_line_id = self.env['rule.line'].browse(adv_rule_id)
|
||||
if not rule_line_id:
|
||||
return discount, product_price
|
||||
adv_new_price = 0.0
|
||||
currency_id = False
|
||||
if rule_line_id.rule_type == 'percent':
|
||||
if not rule_line_id:
|
||||
adv_new_price, currency_id = self.with_context(
|
||||
context_partner)._get_real_price_currency(
|
||||
self.product_id, False,
|
||||
@ -535,11 +559,19 @@ class SaleOrderLine(models.Model):
|
||||
self.product_uom,
|
||||
self.order_id.pricelist_id.id)
|
||||
else:
|
||||
adv_new_price, currency_id = self.with_context(
|
||||
context_partner)._get_real_price_currency_flectra(
|
||||
self.product_id,
|
||||
self.product_uom,
|
||||
self.order_id.pricelist_id, self.price_unit)
|
||||
if rule_line_id.rule_type == 'percent':
|
||||
adv_new_price, currency_id = self.with_context(
|
||||
context_partner)._get_real_price_currency(
|
||||
self.product_id, False,
|
||||
self.product_uom_qty,
|
||||
self.product_uom,
|
||||
self.order_id.pricelist_id.id)
|
||||
elif rule_line_id.rule_type == 'fixed_amount':
|
||||
adv_new_price, currency_id = self.with_context(
|
||||
context_partner)._get_real_price_currency_advance(
|
||||
self.product_id,
|
||||
self.product_uom,
|
||||
self.order_id.pricelist_id, self.price_unit)
|
||||
if adv_new_price != 0:
|
||||
if self.order_id.pricelist_id.currency_id.id != currency_id:
|
||||
adv_new_price = self.env['res.currency'].browse(
|
||||
|
@ -7,3 +7,7 @@ access_rule_line_manager,access_rule_line_manager,model_rule_line,base.group_par
|
||||
access_price_rule_manager,access_price_rule_manager,model_price_rule,base.group_partner_manager,1,0,0,0
|
||||
access_cart_rule_manager,access_cart_rule_manager,model_cart_rule,base.group_partner_manager,1,0,0,0
|
||||
access_coupon_code_manager,access_coupon_code_manager,model_coupon_code,base.group_partner_manager,1,0,0,0
|
||||
access_rule_line_public,access_rule_line_public,model_rule_line,,1,0,0,0
|
||||
access_price_rule_public,access_price_rule_public,model_price_rule,,1,0,0,0
|
||||
access_cart_rule_public,access_cart_rule_public,model_cart_rule,,1,0,0,0
|
||||
access_coupon_code_public,access_coupon_code_public,model_coupon_code,,1,0,0,0
|
||||
|
|
@ -13,19 +13,19 @@
|
||||
<div class="oe_demo oe_picture oe_screenshot">
|
||||
<p class="mt32 text-justify">
|
||||
<h4>- Add new option Pricelist Type (Basic, Advanced).</h4></br>
|
||||
<h4>- Apply Method :-</h4></br>
|
||||
<h4>- Apply Method:</h4></br>
|
||||
<UL>
|
||||
<li> <b>Apply First Matched Rules</b> (Calculate discount of first match condition of Price Rules and Cart Rules)</li>
|
||||
<li> <b>Apply All Matched Rules</b> (Calculate discount of all match condition of Price Rules and Cart Rules)</li>
|
||||
<li> <b>Apply Smallest Matched Discount</b> (Append minimum discount of every match condition of Price Rules and Cart Rules and get minimum values from the list of Price Rules and Cart Rules)</li>
|
||||
<li> <b>Apply Biggest Matched Discount</b> (Append maximum discount of every match condition of Price Rules and Cart Rules and get maximum values from the list of Price Rules and Cart Rules)</li>
|
||||
</UL>
|
||||
<h4> Price Rules applicable on the selected option:-</h4>
|
||||
<h4> Price Rules applicable to the selected option:-</h4>
|
||||
<ul>
|
||||
<li><b>Global: </b> Apply for all Product.</li>
|
||||
<li><b>Category: </b> Apply only for selected category.</li>
|
||||
<li><b>Category: </b> Apply only for the selected category.</li>
|
||||
<li><b>Product Template: </b>Apply only for selected Product Template variants.</li>
|
||||
<li><b>Product Variant:</b>Apply only for selected Product variants.</li>
|
||||
<li><b>Product Variant: </b>Apply only for selected Product variants.</li>
|
||||
</ul>
|
||||
<h4>- Product Rules Line:-</h4></br>
|
||||
<ul> <li>Discount applicable based on match condition which defines in Product Rules Line.</li></ul>
|
||||
@ -48,18 +48,18 @@
|
||||
<div class="row oe_spaced">
|
||||
<div class="oe_demo oe_picture oe_screenshot">
|
||||
<p class="mt32 text-justify">
|
||||
<h4>- Apply On :-</h4></br>
|
||||
<h4>- Apply On:</h4></br>
|
||||
<UL>
|
||||
<li> <b>Subtotal At Least :-</b> Cart Rules not apply if Untaxed Amount is less than define amount in cart line.</li>
|
||||
<li> <b>Subtotal less than :-</b> Cart Rules apply if Untaxed Amount is less than define amount in cart line.</li>
|
||||
<li> <b>Lines Count at least :-</b> Cart Rules not apply if line count of sale order(duplicate product exclude) is less than define amount in cart line.</li>
|
||||
<li> <b>Lines less than :-</b> Cart Rules apply if line count of sale order(duplicate product exclude) is less than define amount in cart line.</li>
|
||||
<li> <b>Sum of Item Qty at least :-</b> Cart Rules is not apply if total quantity of product in sale order is less than define amount in cart line.</li>
|
||||
<li> <b>Sum of Item Qty less than :-</b> Cart Rules apply if the total quantity of product in sale order is less than define amount in cart line.</li>
|
||||
<li> <b>At least one product in order :-</b> Cart Rules apply if product match in sale order which defines in cart line.</li>
|
||||
<li> <b>None of selected Products :-</b> Cart Rules do not apply if product match in sale order which defines in cart line.</li>
|
||||
<li> <b>At least one category in order :-</b> Cart Rules apply if product category match in sale order which defines in cart line.</li>
|
||||
<li> <b>None of selected Categories :-</b> Cart Rules do not apply if product category match in sale order which defines in cart line.</li>
|
||||
<li> <b>Subtotal At Least:</b> Cart Rules do not apply if Untaxed Amount is less than define amount in cart line.</li>
|
||||
<li> <b>Subtotal less than:</b> Cart Rules apply if Untaxed Amount is less than define amount in cart line.</li>
|
||||
<li> <b>Lines Count at least:</b> Cart Rules not apply if line count of sale order(duplicate product exclude) is less than define amount in cart line.</li>
|
||||
<li> <b>Lines less than:</b> Cart Rules apply if line count of sale order(duplicate product exclude) is less than define amount in cart line.</li>
|
||||
<li> <b>Sum of Item Qty at least:</b> Cart Rules is do not apply if the total quantity of product in sale order is less than define amount in cart line.</li>
|
||||
<li> <b>Sum of Item Qty less than:</b> Cart Rules apply if the total quantity of product in sale order is less than define amount in cart line.</li>
|
||||
<li> <b>At least one product in order:</b> Cart Rules apply if product match in sale order which defines in cart line.</li>
|
||||
<li> <b>None of selected Products:</b> Cart Rules do not apply if product match in sale order which defines in cart line.</li>
|
||||
<li> <b>At least one category in order:</b> Cart Rules apply if product category match in sale order which defines in cart line.</li>
|
||||
<li> <b>None of selected Categories:</b> Cart Rules do not apply if product category match in sale order which defines in cart line.</li>
|
||||
</UL>
|
||||
</p>
|
||||
</div>
|
||||
@ -80,15 +80,15 @@
|
||||
<div class="row oe_spaced">
|
||||
<div class="oe_demo oe_picture oe_screenshot">
|
||||
<p class="mt32 text-justify">
|
||||
<h4>- Apply Coupon Code:</h4> Select apply coupon code option in pricelist for apply coupon code.</br>
|
||||
<h4>- Apply Coupon Code:</h4> Select apply coupon code option in pricelist for the apply coupon code.</br>
|
||||
<h4>- Coupon Type:</h4>
|
||||
<UL>
|
||||
<li> <b>Percent :-</b> Add Percentage in sale order line which defines in Discount Amount.</li>
|
||||
<li> <b>Fixed Amount :-</b> Convert fixed amount values in percentage based on the unit price of sale order line.</li>
|
||||
<li> <b>Buy X Product Get Y Product Free :-</b> Get Y same product unit free when buying X product.</li>
|
||||
<li> <b>Buy X Product Get Y Other Product Free :-</b> Get Y other product(which define in coupon code) unit free when buying X product.</li>
|
||||
<li> <b>Range Based Discount(Buy X Product Get Percent Free) :-</b> Get percent free(which define in coupon code) when buying X product.</li>
|
||||
<li> <b>Clubbed Discount :-</b> Add Discount and Extra Discount on Sale order line.</li>
|
||||
<li> <b>Percent:</b> Add Percentage in sale order line which defines in Discount Amount.</li>
|
||||
<li> <b>Fixed Amount:</b> Convert fixed amount values in percentage based on the unit price of sale order line.</li>
|
||||
<li> <b>Buy X Product Get Y Product Free:</b> Get Y same product unit free when buying X product.</li>
|
||||
<li> <b>Buy X Product Get Y Other Product Free:</b> Get Y other product(which define in coupon code) unit free when buying X product.</li>
|
||||
<li> <b>Range Based Discount(Buy X Product Get Percent Free):</b> Get percent free(which define in coupon code) when buying X product.</li>
|
||||
<li> <b>Clubbed Discount:</b> Add Discount and Extra Discount on Sale order line.</li>
|
||||
</UL>
|
||||
</p>
|
||||
</div>
|
||||
@ -129,28 +129,28 @@
|
||||
<div class="row oe_spaced">
|
||||
<div class="col-md-6">
|
||||
<p class="mt32 mb32 text-justify">
|
||||
<h4>First order line discount caculation:</h4> </br>
|
||||
<h4>First order line discount calculation:</h4> </br>
|
||||
<p style="margin-left: 20px;">First order line quantity 5 is between 1 to 5 in Product Rule Line.</p>
|
||||
<p style="margin-left: 20px;">Here define fixed amount = 50 in match Product Rule Line.</p>
|
||||
<p style="margin-left: 20px;">Percentage Formule = Discount Amount * 100 / Unit Price</p>
|
||||
<p style="margin-left: 20px;">50 * 100 / 885 = 5.65</p>
|
||||
<p style="margin-left: 20px;">6.5 % of Match first Cart Rules beacuse Subtotal(Untaxed Amount) At Least : 2,500.00.</p>
|
||||
<p style="margin-left: 20px;">6.5 % of Match first Cart Rules because Subtotal(Untaxed Amount) At Least: 2,500.00.</p>
|
||||
<p style="margin-left: 20px;">Discount Formula= <b> Product Rule line + Cart Rules</b></p>
|
||||
<p style="margin-left: 20px;">so discount is <b>5.65 + 6.5 = 12.15%</b></p>
|
||||
</p>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<p class="mt32 mb32 text-justify">
|
||||
<h4> Second order line discount caculation:</h4> </br>
|
||||
<h4> Second order line discount calculation:</h4> </br>
|
||||
<p style="margin-left: 20px;">Second order line quantity 3 is between 1 to 5 in Product Rule Line.</p>
|
||||
<p style="margin-left: 20px;">Discount = Discount Amount * 100 / Unit Price</p>
|
||||
<p style="margin-left: 20px;">50 * 100 / 2950 = 1.69</p>
|
||||
<p style="margin-left: 20px;">6.5 % of Match first Cart Rules beacuse Subtotal(Untaxed Amount) At Least : 2,500.00.</p>
|
||||
<p style="margin-left: 20px;">6.5 % of Match first Cart Rules because Subtotal(Untaxed Amount) At Least: 2,500.00.</p>
|
||||
<p style="margin-left: 20px;">so discount is <b> 1.69 + 6.5 = 8.19%</b></p>
|
||||
<h4> Third order line discount caculation:</h4> </br>
|
||||
<h4> Third order line discount calculation:</h4> </br>
|
||||
<p style="margin-left: 20px;">Third order line quantity 3 is between 1 to 5 in Product Rule Line.</p>
|
||||
<p style="margin-left: 20px;">Unit Price(25) is less than Fixed Amount(50) of Product Rule Lines.</p>
|
||||
<p style="margin-left: 20px;">so, it give <b> 100% </b> discount for that line.</p>
|
||||
<p style="margin-left: 20px;">so, it gives <b> 100% </b> discount for that line.</p>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
@ -191,12 +191,12 @@
|
||||
<div class="row oe_spaced">
|
||||
<div class="oe_demo oe_picture oe_screenshot">
|
||||
<p class="text-justify">
|
||||
<h4>First order line discount caculation:</h4> </br>
|
||||
<h4>First order line discount calculation:</h4> </br>
|
||||
<p style="margin-left: 20px;"><b>Product Lines Rules:</b></p>
|
||||
<p style="margin-left: 20px;">4.9 % of Match first Product Rule Lines beacuse ordered Qty 5 is between 1 to 6.</p>
|
||||
<p style="margin-left: 20px;">4.9 % of Match first Product Rule Lines because ordered Qty 5 is between 1 to 6.</p>
|
||||
<p style="margin-left: 20px;"><b>Cart Rules:</b></p>
|
||||
<p style="margin-left: 20px;">First cart Rules not match beacuse Subtotal is greater than : 3,000.00 so that rules skip.</p>
|
||||
<p style="margin-left: 20px;">Second Cart Rules match beacuse Sum of Item Qty at least : 7.00 (here 8 = 5 + 3 ). so add 10 %.</p>
|
||||
<p style="margin-left: 20px;">First cart Rules do not match because Subtotal is greater than 3,000.00 so that rules skip.</p>
|
||||
<p style="margin-left: 20px;">Second Cart Rules match because Sum of Item Qty At Least: 7.00 (here 8 = 5 + 3 ). so add 10 %.</p>
|
||||
<p style="margin-left: 20px;"><b>Coupon Code: Coupon code get 10 percent free.</b>
|
||||
<p style="margin-left: 20px;">Discount Formula= <b> Product Rule line + Cart Rules + Coupon Code</b></p>
|
||||
<p style="margin-left: 20px;">First line discount is 24.9 %( 4.9 + 10 + 10)</p>
|
||||
|
@ -112,10 +112,9 @@ class TestMixAllDiscount(TestAdvSalePricelist):
|
||||
|
||||
first_order_line = self.sale_order.order_line[0]
|
||||
first_order_line._onchange_discount()
|
||||
self.assertEqual(first_order_line.discount, 12.5,
|
||||
self.assertEqual(first_order_line.discount, 19.0,
|
||||
'Discount Percentage: the discount for the'
|
||||
' sale order line should be 12.5!')
|
||||
self.sale_order._check_cart_rules()
|
||||
' sale order line should be 19.0!')
|
||||
|
||||
# Set coupon code with percent
|
||||
self.check_all_condition(self.sale_order, 'percent')
|
||||
@ -142,11 +141,6 @@ class TestMixAllDiscount(TestAdvSalePricelist):
|
||||
|
||||
first_order_line = self.sale_order_1.order_line[0]
|
||||
first_order_line._onchange_discount()
|
||||
self.assertEqual(first_order_line.discount, 15.00,
|
||||
'Discount Percentage: the discount for the'
|
||||
' first sale order line should be 15!')
|
||||
|
||||
self.sale_order_1._check_cart_rules()
|
||||
self.assertEqual(first_order_line.discount, 21.50,
|
||||
'Discount Percentage: the discount for the'
|
||||
' first sale order line should be 21.50!')
|
||||
@ -162,11 +156,7 @@ class TestMixAllDiscount(TestAdvSalePricelist):
|
||||
|
||||
self.coupon_code_id.write({'coupon_type': coupon_type,
|
||||
'apply_on': 'category',
|
||||
'categ_id': self.category_id.id,
|
||||
'discount_amount': 0.0,
|
||||
'number_of_y_product': 0.0,
|
||||
'number_of_y_product': 0.0,
|
||||
'other_product_id': False})
|
||||
'categ_id': self.category_id.id})
|
||||
if coupon_type in ['percent', 'fixed_amount']:
|
||||
self.coupon_code_id.write({'discount_amount': 20})
|
||||
elif coupon_type == 'buy_x_get_percent':
|
||||
@ -181,6 +171,7 @@ class TestMixAllDiscount(TestAdvSalePricelist):
|
||||
'number_of_y_product': 1,
|
||||
'discount_amount': 0.0,
|
||||
'other_product_id': self.product_3.id})
|
||||
self.coupon_code_id.check_percentage()
|
||||
# Category Coupon Code
|
||||
self.check_all_coupon_code(sale_order,
|
||||
'GetDiscount', self.pricelist_id)
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<flectra>
|
||||
<record id="product_pricelist_view_flectra" model="ir.ui.view">
|
||||
<field name="name">product.pricelist.flectra.form</field>
|
||||
<record id="product_pricelist_view_advance" model="ir.ui.view">
|
||||
<field name="name">product.pricelist.advance.form</field>
|
||||
<field name="model">product.pricelist</field>
|
||||
<field name="inherit_id" ref="product.product_pricelist_view"/>
|
||||
<field name="arch" type="xml">
|
||||
|
@ -1,8 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<flectra>
|
||||
|
||||
<record id="view_order_form_flectra" model="ir.ui.view">
|
||||
<field name="name">sale.order.flectra.form</field>
|
||||
<record id="view_order_form_advance" model="ir.ui.view">
|
||||
<field name="name">sale.order.advance.form</field>
|
||||
<field name="model">sale.order</field>
|
||||
<field name="inherit_id" ref="sale.view_order_form"/>
|
||||
<field name="arch" type="xml">
|
||||
|
@ -21,7 +21,8 @@ class SaleOrder(models.Model):
|
||||
record.discount = record.pricelist_id.currency_id.round(total_discount)
|
||||
|
||||
@api.multi
|
||||
@api.depends('order_line', 'discount_per', 'discount_amount')
|
||||
@api.depends('order_line', 'discount_per', 'discount_amount',
|
||||
'order_line.product_uom_qty', 'order_line.price_unit')
|
||||
def _get_total_amount(self):
|
||||
for order_id in self:
|
||||
order_id.gross_amount = sum(
|
||||
|
Loading…
Reference in New Issue
Block a user