[IMP] deliver: add fixed margin
Removed the margin on rate when the provider is Fixed Price Removed the margin on rate, free, amount when the provider is Based on Rules Added a fixed margin for all the other providers task-3043063 closes odoo/odoo#108794 Signed-off-by: Steve Van Essche <svs@odoo.com>
This commit is contained in:
@@ -69,6 +69,7 @@ class DeliveryCarrier(models.Model):
|
||||
"E.g. instructions for customers to follow.")
|
||||
|
||||
margin = fields.Float(help='This percentage will be added to the shipping price.')
|
||||
fixed_margin = fields.Float(help='This fixed amount will be added to the shipping price.')
|
||||
free_over = fields.Boolean('Free if order amount is above', help="If the order total amount (shipping excluded) is above or equal to this value, the customer benefits from a free shipping", default=False)
|
||||
amount = fields.Float(string='Amount', help="Amount of the order to benefit from a free shipping, expressed in the company currency")
|
||||
|
||||
@@ -199,7 +200,7 @@ class DeliveryCarrier(models.Model):
|
||||
product_currency=company.currency_id
|
||||
)
|
||||
# apply margin on computed price
|
||||
res['price'] = float(res['price']) * (1.0 + (self.margin / 100.0))
|
||||
res['price'] = float(res['price']) * (1.0 + (self.margin / 100.0)) + self.fixed_margin
|
||||
# save the real price in case a free_over rule overide it to 0
|
||||
res['carrier_price'] = res['price']
|
||||
# free when order is large enough
|
||||
|
||||
@@ -97,12 +97,13 @@
|
||||
<group name="delivery_details">
|
||||
<field name="product_id" context="{'default_detailed_type': 'service', 'default_sale_ok': False, 'default_purchase_ok': False, 'default_invoice_policy': 'order'}" />
|
||||
<field name="invoice_policy" widget="radio" attrs="{'invisible': ['|', ('delivery_type', 'in', ('fixed', 'base_on_rule')), ('integration_level', '=', 'rate')]}"/>
|
||||
<label for="margin" string="Margin on Rate"/>
|
||||
<div>
|
||||
<label for="margin" string="Margin on Rate" attrs="{'invisible': [('delivery_type', '=', 'fixed')]}"/>
|
||||
<div attrs="{'invisible': [('delivery_type', '=', 'fixed')]}">
|
||||
<field name="margin" class="oe_inline"/>%
|
||||
</div>
|
||||
<field name="free_over"/>
|
||||
<field name="amount" attrs="{'required':[('free_over','!=', False)], 'invisible':[('free_over','=', False)]}"/>
|
||||
<field name="fixed_margin" attrs="{'invisible': [('delivery_type', '=', 'fixed')]}"/>
|
||||
<field name="free_over" attrs="{'invisible': [('delivery_type', '=', ('base_on_rule'))]}"/>
|
||||
<field name="amount" attrs="{'required':[('free_over','!=', False)], 'invisible':['|',('free_over','=', False),('delivery_type', '=', ('base_on_rule'))]}"/>
|
||||
<field name="supports_shipping_insurance" invisible="1"/>
|
||||
<label for="shipping_insurance" String="Shipping Insurance" attrs="{'invisible': [('supports_shipping_insurance', '=', False)]}"/>
|
||||
<div attrs="{'invisible': [('supports_shipping_insurance', '=', False)]}">
|
||||
|
||||
Reference in New Issue
Block a user