[REF] delivery: remove inherits with product.product

(Actually, a good old m2o is enough.)

We also clean a bit the delivery.carrier view.
This commit is contained in:
Richard Mathot
2017-07-20 15:32:21 +02:00
parent 6999d054fc
commit 45ca8f41d6
5 changed files with 45 additions and 33 deletions
+11 -5
View File
@@ -1,17 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data noupdate="1">
<record id="product_product_delivery" model="product.product">
<field name="name">Free delivery charges</field>
<field name="default_code">Delivery</field>
<field name="type">service</field>
<field name="categ_id" ref="product.product_category_all"/>
<field name="sale_ok" eval="False"/>
<field name="purchase_ok" eval="False"/>
<field name="list_price">0.0</field>
</record>
<record id="free_delivery_carrier" model="delivery.carrier">
<field name="name">Free delivery charges</field>
<field name="fixed_price">0</field>
<field name="fixed_price">0.0</field>
<field name="free_over" eval="True"/>
<field name="amount">1000</field>
<field name="sequence">1</field>
<field name="delivery_type">fixed</field>
<field name="product_type">service</field>
<field name="product_sale_ok" eval="False"/>
<field name="product_id" ref="delivery.product_product_delivery"/>
</record>
</data>
</odoo>
+24 -9
View File
@@ -4,29 +4,46 @@
<!-- Carrier -->
<record id="product_product_delivery_poste" model="product.product">
<field name="name">The Poste</field>
<field name="default_code">Delivery</field>
<field name="type">service</field>
<field name="categ_id" ref="product.product_category_all"/>
<field name="sale_ok" eval="False"/>
<field name="purchase_ok" eval="False"/>
<field name="list_price">20.0</field>
</record>
<record id="delivery_carrier" model="delivery.carrier">
<field name="name">The Poste</field>
<field name="fixed_price">20</field>
<field name="fixed_price">20.0</field>
<field name="sequence">2</field>
<field name="delivery_type">base_on_rule</field>
<field name="product_type">service</field>
<field name="product_sale_ok" eval="False"/>
<field name="product_id" ref="delivery.product_product_delivery_poste"/>
</record>
<record id="product_product_delivery_normal" model="product.product">
<field name="name">Normal Delivery Charges</field>
<field name="default_code">Delivery</field>
<field name="type">service</field>
<field name="categ_id" ref="product.product_category_all"/>
<field name="sale_ok" eval="False"/>
<field name="purchase_ok" eval="False"/>
<field name="list_price">10.0</field>
</record>
<record id="normal_delivery_carrier" model="delivery.carrier">
<field name="name">Normal Delivery Charges</field>
<field name="fixed_price">10</field>
<field name="fixed_price">10.0</field>
<field name="sequence">3</field>
<field name="delivery_type">fixed</field>
<field name="product_type">service</field>
<field name="product_sale_ok" eval="False"/>
<field name="product_id" ref="delivery.product_product_delivery_normal"/>
</record>
<record id="delivery_price_rule1" model="delivery.price.rule">
<field name="carrier_id" ref="delivery_carrier"/>
<field eval="5" name="max_value"/>
<field eval="20" name="list_base_price"/>
<field eval="10" name="standard_price"/>
</record>
<!-- delivery charge of product if weight more than 5kg-->
<record id="delivery_price_rule2" model="delivery.price.rule">
@@ -34,7 +51,6 @@
<field name="operator">&gt;=</field>
<field eval="5" name="max_value"/>
<field eval="50" name="list_base_price"/>
<field eval="30" name="standard_price"/>
</record>
<!-- free delivery charge if price more than 300-->
@@ -44,7 +60,6 @@
<field name="operator">&gt;=</field>
<field name="variable">price</field>
<field eval="0" name="list_base_price"/>
<field eval="0" name="standard_price"/>
</record>
<record forcecreate="True" id="property_delivery_carrier" model="ir.property">
+4 -6
View File
@@ -10,7 +10,6 @@ _logger = logging.getLogger(__name__)
class DeliveryCarrier(models.Model):
_name = 'delivery.carrier'
_inherits = {'product.product': 'product_id'}
_description = "Carrier"
_order = 'sequence, id'
@@ -33,16 +32,15 @@ class DeliveryCarrier(models.Model):
# Internals for shipping providers #
# -------------------------------- #
name = fields.Char(required=True)
active = fields.Boolean(default=True)
sequence = fields.Integer(help="Determine the display order", default=10)
# This field will be overwritten by internal shipping providers by adding their own type (ex: 'fedex')
delivery_type = fields.Selection([('fixed', 'Fixed Price')], string='Provider', default='fixed', required=True)
integration_level = fields.Selection([('rate', 'Get Rate'), ('rate_and_ship', 'Get Rate and Create Shipment')], string="Integration Level", default='rate_and_ship', help="Action while validating Delivery Orders")
prod_environment = fields.Boolean("Environment", help="Set to True if your credentials are certified for production.")
company_id = fields.Many2one('res.company', string='Company', related='product_id.company_id', store=True)
product_type = fields.Selection(related='product_id.type', default='service')
product_sale_ok = fields.Boolean(related='product_id.sale_ok', default=False)
product_id = fields.Many2one('product.product', string='Delivery Product', required=True, ondelete="cascade")
product_id = fields.Many2one('product.product', string='Delivery Product', required=True, ondelete='restrict')
country_ids = fields.Many2many('res.country', 'delivery_carrier_country_rel', 'carrier_id', 'country_id', 'Countries')
state_ids = fields.Many2many('res.country.state', 'delivery_carrier_state_rel', 'carrier_id', 'state_id', 'States')
@@ -50,7 +48,7 @@ class DeliveryCarrier(models.Model):
zip_to = fields.Char('Zip To')
margin = fields.Integer(help='This percentage will be added to the shipping price.')
free_over = fields.Boolean('Free if Order total is more than', help="If the order is more expensive than a certain amount, the customer can benefit from a free shipping", default=False, oldname='free_if_more_than')
free_over = fields.Boolean('Free if order total is more than', help="If the order is more expensive than a certain amount, the customer can benefit from a free shipping", default=False, oldname='free_if_more_than')
amount = fields.Float(string='Amount', help="Amount of the order to benefit from a free shipping, expressed in the company currency")
_sql_constraints = [
-3
View File
@@ -35,9 +35,6 @@ class PriceRule(models.Model):
list_price = fields.Float('Sale Price', digits=dp.get_precision('Product Price'), required=True, default=0.0)
variable_factor = fields.Selection([('weight', 'Weight'), ('volume', 'Volume'), ('wv', 'Weight * Volume'), ('price', 'Price'), ('quantity', 'Quantity')], 'Variable Factor', required=True, default='weight')
# TODO remove me, should be replaced by fixed price
standard_price = fields.Float('Cost Price', digits=dp.get_precision('Product Price'), required=True, default=0.0)
class ProviderGrid(models.Model):
_inherit = 'delivery.carrier'
+6 -10
View File
@@ -73,23 +73,20 @@
<field name="delivery_type" widget="radio"/>
<button string="Install more Providers" name="install_more_provider" type="object" class="oe_link oe_edit_only"/>
</div>
<field name="integration_level" widget="radio" attrs="{'invisible': ['|', ('delivery_type', '=', 'fixed'), ('delivery_type', '=', 'base_on_rule')]}"/>
</group>
<group>
<field name="integration_level" widget="radio" attrs="{'invisible': ['|', ('delivery_type', '=', 'fixed'), ('delivery_type', '=', 'base_on_rule')]}"/>
<label for="margin" string="Margin on Rate"/>
<div>
<field name="margin" class="oe_inline"/>%
</div>
</group>
<group>
<div class="o_row">
<label for="free_over"/>
<div class="o_row o_td_label">
<field name="free_over"/>
<field nolabel="1" name="amount" attrs="{'required':[('free_over','!=', False)], 'invisible':[('free_over','=', False)]}"/>
<label for="free_over"/>
</div>
</group>
<group>
<field name="company_id"/>
<field nolabel="1" name="amount" attrs="{'required':[('free_over','!=', False)], 'invisible':[('free_over','=', False)]}"/>
<field name="product_id" context="{'default_type': 'service', 'sale_ok': False, 'purchase_ok': False}" />
<field name="company_id" groups="base.group_multi_company"/>
</group>
</group>
<notebook>
@@ -177,7 +174,6 @@
*
<field name="variable_factor" class="oe_inline"/>
</div>
<field name="standard_price" invisible="1"/>
</group>
</form>
</field>