[FIX] delivery methods
bzr revid: fp@tinyerp.com-20111001221803-d5dchaux0pzjozqo
This commit is contained in:
parent
431a33d0f9
commit
142313d012
|
@ -61,16 +61,16 @@ class delivery_carrier(osv.osv):
|
|||
return res
|
||||
|
||||
_columns = {
|
||||
'name': fields.char('Carrier', size=64, required=True),
|
||||
'partner_id': fields.many2one('res.partner', 'Carrier Partner', required=True),
|
||||
'name': fields.char('Delivery Method', size=64, required=True),
|
||||
'partner_id': fields.many2one('res.partner', 'Transport Company', required=True, help="The partner that is doing the delivery service."),
|
||||
'product_id': fields.many2one('product.product', 'Delivery Product', required=True),
|
||||
'grids_id': fields.one2many('delivery.grid', 'carrier_id', 'Delivery Grids'),
|
||||
'price' : fields.function(get_price, string='Price'),
|
||||
'active': fields.boolean('Active', help="If the active field is set to False, it will allow you to hide the delivery carrier without removing it."),
|
||||
'normal_price': fields.float('Normal Price'),
|
||||
'free_if_more_than': fields.boolean('Free If More Than'),
|
||||
'amount': fields.float('Amount'),
|
||||
'use_detailed_pricelist': fields.boolean('Use Detailed Pricelist'),
|
||||
'normal_price': fields.float('Normal Price', help="Keep empty if the pricing depends on the advanced pricing per destination"),
|
||||
'free_if_more_than': fields.boolean('Free If More Than', help="If the order is more expensive than a certain amount, the customer can benefit from a free shipping"),
|
||||
'amount': fields.float('Amount', help="Amount of the order to benefit from a free shipping, expressed in the company currency"),
|
||||
'use_detailed_pricelist': fields.boolean('Advanced Pricing per Destination', help="Check this box if you want to manage delivery prices that depends on the destination, the weight, the total of the order, etc."),
|
||||
'pricelist_ids': fields.one2many('delivery.grid', 'carrier_id', 'Advanced Pricing'),
|
||||
}
|
||||
|
||||
|
@ -103,25 +103,32 @@ class delivery_carrier(osv.osv):
|
|||
grid_line_pool = self.pool.get('delivery.grid.line')
|
||||
grid_pool = self.pool.get('delivery.grid')
|
||||
for record in self.browse(cr, uid, ids, context=context):
|
||||
grid_id = grid_pool.search(cr, uid, [('carrier_id', '=', record.id)], context=context)
|
||||
grid_id = grid_pool.search(cr, uid, [('carrier_id', '=', record.id),('sequence','=',9999)], context=context)
|
||||
|
||||
if grid_id and not (record.normal_price or record.free_if_more_than):
|
||||
grid_pool.unlink(cr, uid, grid_id, context=context)
|
||||
|
||||
if not (record.normal_price or record.free_if_more_than):
|
||||
continue
|
||||
|
||||
if not grid_id:
|
||||
record_data = {
|
||||
'name': vals.get('name', False),
|
||||
'name': record.name,
|
||||
'carrier_id': record.id,
|
||||
'seqeunce': 10,
|
||||
'sequence': 9999,
|
||||
}
|
||||
new_grid_id = grid_pool.create(cr, uid, record_data, context=context)
|
||||
grid_id = [new_grid_id]
|
||||
|
||||
#delete all existing grid lines
|
||||
grid_lines = [line.id for line in grid_pool.browse(cr, uid, grid_id[0]).line_ids if line.type == 'price']
|
||||
grid_line_pool.unlink(cr, uid, grid_lines, context=context)
|
||||
lines = grid_line_pool.search(cr, uid, [('grid_id','in',grid_id)], context=context)
|
||||
if lines:
|
||||
grid_line_pool.unlink(cr, uid, lines, context=context)
|
||||
|
||||
#create the grid lines
|
||||
if record.free_if_more_than:
|
||||
data = {
|
||||
'grid_id': grid_id and grid_id[0],
|
||||
'name': _('Free if more than %d') % record.amount,
|
||||
'name': _('Free if more than %.2f') % record.amount,
|
||||
'type': 'price',
|
||||
'operator': '>=',
|
||||
'max_value': record.amount,
|
||||
|
@ -217,7 +224,7 @@ class delivery_grid_line(osv.osv):
|
|||
_description = "Delivery Grid Line"
|
||||
_columns = {
|
||||
'name': fields.char('Name', size=32, required=True),
|
||||
'grid_id': fields.many2one('delivery.grid', 'Grid',required=True),
|
||||
'grid_id': fields.many2one('delivery.grid', 'Grid',required=True, ondelete='cascade'),
|
||||
'type': fields.selection([('weight','Weight'),('volume','Volume'),\
|
||||
('wv','Weight * Volume'), ('price','Price')],\
|
||||
'Variable', required=True),
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Carrier">
|
||||
<field name="name"/>
|
||||
<field name="partner_id"/>
|
||||
<field name="price" invisible="'order_id' not in context"/>
|
||||
</tree>
|
||||
|
@ -21,15 +22,16 @@
|
|||
<field name="arch" type="xml">
|
||||
<form string="Carrier">
|
||||
<group colspan="4" col="4" name="general">
|
||||
<field name="name" select="1"/>
|
||||
<field name="partner_id" select="1"/>
|
||||
<field name="product_id" select="1"/>
|
||||
<field name="active" select="1"/>
|
||||
<separator string="Pricing Information" colspan="6"/>
|
||||
<group colspan="2" col="4">
|
||||
<field name="normal_price" select="1" colspan="4"/>
|
||||
<separator string="Pricing Information" colspan="4"/>
|
||||
<group colspan="4" col="4">
|
||||
<field name="normal_price"/>
|
||||
<newline/>
|
||||
<field name="free_if_more_than"/>
|
||||
<field name="amount" attrs="{'invisible':[('free_if_more_than','=',False)]}"/>
|
||||
<field name="amount" attrs="{'required':[('free_if_more_than','<>',False)], 'invisible':[('free_if_more_than','=',False)]}"/>
|
||||
</group>
|
||||
<newline/>
|
||||
<field name="use_detailed_pricelist"/>
|
||||
|
@ -37,7 +39,6 @@
|
|||
<field name="pricelist_ids" nolabel="1" attrs="{'invisible':[('use_detailed_pricelist','=',False)]}" mode="tree,form">
|
||||
<tree string="Delivery grids">
|
||||
<field name="sequence"/>
|
||||
<field name="carrier_id"/>
|
||||
<field name="name"/>
|
||||
</tree>
|
||||
<form string="Delivery grids">
|
||||
|
@ -76,8 +77,8 @@
|
|||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">delivery.carrier</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">form,tree</field>
|
||||
<field name="help">Define the delivery methods you are using and their pricing in order to reinvoice the delivery costs when you are doing invoicing based on delivery orders</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
<field name="help">Define your delivery methods and their pricing. The delivery costs can be added on the sale order form or in the invoice, based on the delivery orders.</field>
|
||||
</record>
|
||||
|
||||
<menuitem action="action_delivery_carrier_form" id="menu_action_delivery_carrier_form" parent="menu_delivery"/>
|
||||
|
|
Loading…
Reference in New Issue