summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--addons/mrp_repair/mrp_repair.py20
-rw-r--r--addons/mrp_subproduct/mrp_subproduct.py5
-rw-r--r--addons/product/pricelist.py2
-rw-r--r--addons/product/product.py4
-rw-r--r--addons/purchase/purchase.py23
-rw-r--r--addons/purchase/purchase_view.xml2
-rw-r--r--addons/purchase/wizard/purchase_line_invoice.py6
-rw-r--r--addons/stock/stock.py16
-rw-r--r--addons/stock/stock_view.xml8
9 files changed, 40 insertions, 46 deletions
diff --git a/addons/mrp_repair/mrp_repair.py b/addons/mrp_repair/mrp_repair.py
index b5a3ee783a0..899a7460fdf 100644
--- a/addons/mrp_repair/mrp_repair.py
+++ b/addons/mrp_repair/mrp_repair.py
@@ -336,7 +336,7 @@ class mrp_repair(osv.osv):
"""
mrp_line_obj = self.pool.get('mrp.repair.line')
for repair in self.browse(cr, uid, ids, context=context):
- mrp_line_obj.write(cr, uid, [l.id for l in repair.operations], {'state': 'cancel'})
+ mrp_line_obj.write(cr, uid, [l.id for l in repair.operations], {'state': 'cancel'}, context=context)
self.write(cr,uid,ids,{'state':'cancel'})
return True
@@ -455,7 +455,7 @@ class mrp_repair(osv.osv):
"""
for repair in self.browse(cr, uid, ids, context=context):
self.pool.get('mrp.repair.line').write(cr, uid, [l.id for
- l in repair.operations], {'state': 'confirmed'})
+ l in repair.operations], {'state': 'confirmed'}, context=context)
self.write(cr, uid, [repair.id], {'state': 'ready'})
return True
@@ -470,25 +470,27 @@ class mrp_repair(osv.osv):
""" Writes repair order state to 'Under Repair'
@return: True
"""
+ repair_line = self.pool.get('mrp.repair.line')
for repair in self.browse(cr, uid, ids, context=context):
- self.pool.get('mrp.repair.line').write(cr, uid, [l.id for
- l in repair.operations], {'state': 'confirmed'})
- self.write(cr, uid, [repair.id], {'state': 'under_repair'})
+ repair_line.write(cr, uid, [l.id for
+ l in repair.operations], {'state': 'confirmed'}, context=context)
+ repair.write({'state': 'under_repair'})
return True
def action_invoice_end(self, cr, uid, ids, context=None):
""" Writes repair order state to 'Ready' if invoice method is Before repair.
@return: True
"""
+ repair_line = self.pool.get('mrp.repair.line')
for order in self.browse(cr, uid, ids, context=context):
val = {}
if (order.invoice_method == 'b4repair'):
val['state'] = 'ready'
- self.pool.get('mrp.repair.line').write(cr, uid, [l.id for
- l in order.operations], {'state': 'confirmed'})
+ repair_line.write(cr, uid, [l.id for
+ l in order.operations], {'state': 'confirmed'}, context=context)
else:
pass
- self.write(cr, uid, [order.id], val)
+ self.write(cr, uid, [order.id], val, context=context)
return True
def action_repair_end(self, cr, uid, ids, context=None):
@@ -535,7 +537,7 @@ class mrp_repair(osv.osv):
'tracking_id': False,
'state': 'done',
})
- repair_line_obj.write(cr, uid, [move.id], {'move_id': move_id, 'state': 'done'})
+ repair_line_obj.write(cr, uid, [move.id], {'move_id': move_id, 'state': 'done'}, context=context)
if repair.deliver_bool:
pick_name = seq_obj.get(cr, uid, 'stock.picking.out')
picking = pick_obj.create(cr, uid, {
diff --git a/addons/mrp_subproduct/mrp_subproduct.py b/addons/mrp_subproduct/mrp_subproduct.py
index fe348c853f8..2d7c761da90 100644
--- a/addons/mrp_subproduct/mrp_subproduct.py
+++ b/addons/mrp_subproduct/mrp_subproduct.py
@@ -35,11 +35,8 @@ class mrp_subproduct(osv.osv):
_defaults={
'subproduct_type': lambda *args: 'fixed'
}
- _sql_constraints = [
- ('_check_product_qty', 'CHECK (product_qty > 0)', 'Enter valid product quantity !'),
- ]
- def onchange_product_id(self, cr, uid, ids, product_id,context={}):
+ def onchange_product_id(self, cr, uid, ids, product_id, context=None):
""" Changes UoM if product_id changes.
@param product_id: Changed product_id
@return: Dictionary of changed values
diff --git a/addons/product/pricelist.py b/addons/product/pricelist.py
index e2c4f6735b2..836ac207d29 100644
--- a/addons/product/pricelist.py
+++ b/addons/product/pricelist.py
@@ -538,7 +538,7 @@ class product_pricelist_item(osv.osv):
'categ_id': fields.many2one('product.category', 'Product Category', ondelete='cascade', help="Set a category of product if this rule only apply to products of a category and his childs. Keep empty for all products"),
'min_quantity': fields.integer('Min. Quantity', required=True, help="The rule only applies if the partner buys/sells more than this quantity."),
- 'sequence': fields.integer('Sequence', required=True, help="Gives the sequence order when displaying a list of pricelist items."),
+ 'sequence': fields.integer('Sequence', required=True, help="Gives the order in which the pricelist items will be checked. The evaluation gives highest priority to lowest sequence and stops as soon as a matching item is found."),
'base': fields.selection(_price_field_get, 'Based on', required=True, size=-1, help="The mode for computing the price for this rule."),
'base_pricelist_id': fields.many2one('product.pricelist', 'If Other Pricelist'),
diff --git a/addons/product/product.py b/addons/product/product.py
index fae54f36933..4fc03d0b2b8 100644
--- a/addons/product/product.py
+++ b/addons/product/product.py
@@ -706,7 +706,7 @@ class product_supplierinfo(osv.osv):
'product_code': fields.char('Supplier Product Code', size=64, help="This supplier's product code will be used when printing a request for quotation. Keep empty to use the internal one."),
'sequence' : fields.integer('Sequence', help="Assigns the priority to the list of product supplier."),
'product_uom': fields.many2one('product.uom', string="UOM", help="Supplier Product UoM."),
- 'min_qty': fields.float('Minimal Quantity', required=True, help="The minimal quantity to purchase to this supplier, expressed in the default unit of measure."),
+ 'min_qty': fields.float('Minimal Quantity', required=True, help="The minimal quantity to purchase to this supplier, expressed in the supplier Product UoM if not empty, in the default unit of measure of the product otherwise."),
'qty': fields.function(_calc_qty, method=True, store=True, type='float', string='Quantity', multi="qty", help="This is a quantity which is converted into Default Uom."),
'product_id' : fields.many2one('product.template', 'Product', required=True, ondelete='cascade', select=True),
'delay' : fields.integer('Delivery Lead Time', required=True, help="Lead time in days between the confirmation of the purchase order and the reception of the products in your warehouse. Used by the scheduler for automatic computation of the purchase order planning."),
@@ -775,7 +775,7 @@ class pricelist_partnerinfo(osv.osv):
_columns = {
'name': fields.char('Description', size=64),
'suppinfo_id': fields.many2one('product.supplierinfo', 'Partner Information', required=True, ondelete='cascade'),
- 'min_quantity': fields.float('Quantity', required=True),
+ 'min_quantity': fields.float('Quantity', required=True, help="The minimal quantity to trigger this rule, expressed in the default UoM of the product."),
'price': fields.float('Unit Price', required=True, digits_compute=dp.get_precision('Purchase Price'), help="This price will be considered as a price for default Unit of Measure of the product"),
}
_order = 'min_quantity asc'
diff --git a/addons/purchase/purchase.py b/addons/purchase/purchase.py
index 8d1fb3f8d28..66cee5c1c20 100644
--- a/addons/purchase/purchase.py
+++ b/addons/purchase/purchase.py
@@ -88,15 +88,6 @@ class purchase_order(osv.osv):
res[purchase.id]=min_date
return res
- def _get_invoices(self, cr, uid, ids, name, arg, context=None):
- res = {}
- for purchase in self.browse(cr, uid, ids, context=context):
- invoice_ids = []
- for line in purchase.order_line:
- for inv_line in line.invoice_lines:
- invoice_ids.append(inv_line.invoice_id.id)
- res[purchase.id] = invoice_ids
- return res
def _invoiced_rate(self, cursor, user, ids, name, arg, context=None):
res = {}
@@ -148,9 +139,9 @@ class purchase_order(osv.osv):
def _invoiced(self, cursor, user, ids, name, arg, context=None):
res = {}
for purchase in self.browse(cursor, user, ids, context=context):
- invoiced = []
- for invoice in purchase.invoice_ids:
- invoiced.append(invoice.reconciled)
+ invoiced = False
+ if purchase.invoiced_rate == 100.00:
+ invoiced = True
res[purchase.id] = invoiced
return res
@@ -188,7 +179,7 @@ class purchase_order(osv.osv):
'order_line': fields.one2many('purchase.order.line', 'order_id', 'Order Lines', states={'approved':[('readonly',True)],'done':[('readonly',True)]}),
'validator' : fields.many2one('res.users', 'Validated by', readonly=True),
'notes': fields.text('Notes'),
- 'invoice_ids': fields.function(_get_invoices, method=True, type='many2many', relation="account.invoice", string="Invoice", help="Invoices generated for a purchase order"),
+ 'invoice_ids': fields.many2many('account.invoice', 'purchase_invoice_rel', 'purchase_id', 'invoice_id', 'Taxes', help="Invoices generated for a purchase order"),
'picking_ids': fields.one2many('stock.picking', 'purchase_id', 'Picking List', readonly=True, help="This is the list of picking list that have been generated for this purchase"),
'shipped':fields.boolean('Received', readonly=True, select=True, help="It indicates that a picking has been done"),
'shipped_rate': fields.function(_shipped_rate, method=True, string='Received', type='float'),
@@ -386,7 +377,7 @@ class purchase_order(osv.osv):
inv_id = self.pool.get('account.invoice').create(cr, uid, inv, {'type':'in_invoice'})
self.pool.get('account.invoice').button_compute(cr, uid, [inv_id], {'type':'in_invoice'}, set_total=True)
self.pool.get('purchase.order.line').write(cr, uid, todo, {'invoiced':True})
- self.write(cr, uid, [o.id], {'invoice_ids': [4, inv_id]})
+ self.write(cr, uid, [o.id], {'invoice_ids': [(4, inv_id)]})
res = inv_id
return res
@@ -478,8 +469,8 @@ class purchase_order(osv.osv):
'state':'draft',
'shipped':False,
'invoiced':False,
- 'invoice_ids':{},
- 'picking_ids':[],
+ 'invoice_ids': [],
+ 'picking_ids': [],
'name': self.pool.get('ir.sequence').get(cr, uid, 'purchase.order'),
})
return super(purchase_order, self).copy(cr, uid, id, default, context)
diff --git a/addons/purchase/purchase_view.xml b/addons/purchase/purchase_view.xml
index 5eec9fc1f22..4ffe5ac5f1e 100644
--- a/addons/purchase/purchase_view.xml
+++ b/addons/purchase/purchase_view.xml
@@ -182,7 +182,7 @@
<field name="date_approve"/>
<separator string="Invoices" colspan="4"/>
<newline/>
- <field name="invoice_ids" readonly="1" groups="base.group_extended" nolabel="1" colspan="4"/>
+ <field name="invoice_ids" groups="base.group_extended" nolabel="1" colspan="4"/>
</page>
<page string="Notes">
<field colspan="4" name="notes" nolabel="1"/>
diff --git a/addons/purchase/wizard/purchase_line_invoice.py b/addons/purchase/wizard/purchase_line_invoice.py
index 26dedb158a7..f22df7aef41 100644
--- a/addons/purchase/wizard/purchase_line_invoice.py
+++ b/addons/purchase/wizard/purchase_line_invoice.py
@@ -52,6 +52,7 @@ class purchase_line_invoice(osv.osv_memory):
invoices = {}
invoice_obj=self.pool.get('account.invoice')
purchase_line_obj=self.pool.get('purchase.order.line')
+ purchase_obj = self.pool.get('purchase.order')
property_obj=self.pool.get('ir.property')
account_fiscal_obj=self.pool.get('account.fiscal.position')
invoice_line_obj=self.pool.get('account.invoice.line')
@@ -108,6 +109,8 @@ class purchase_line_invoice(osv.osv_memory):
'fiscal_position': partner.property_account_position.id
}
inv_id = invoice_obj.create(cr, uid, inv)
+ for order in orders:
+ order.write({'invoice_ids': [(4, inv_id)]})
return inv_id
for line in purchase_line_obj.browse(cr,uid,record_ids):
@@ -141,8 +144,7 @@ class purchase_line_invoice(osv.osv_memory):
'note': line.notes,
'account_analytic_id': line.account_analytic_id and line.account_analytic_id.id or False,
})
- cr.execute('insert into purchase_order_line_invoice_rel (order_line_id,invoice_id) values (%s,%s)', (line.id, inv_id))
- purchase_line_obj.write(cr, uid, [line.id], {'invoiced': True})
+ purchase_line_obj.write(cr, uid, [line.id], {'invoiced': True, 'invoice_lines': [(4, inv_id)]})
invoices[line.partner_id.id].append((line,inv_id))
res = []
diff --git a/addons/stock/stock.py b/addons/stock/stock.py
index 209848f7da6..81efdbca71e 100644
--- a/addons/stock/stock.py
+++ b/addons/stock/stock.py
@@ -1617,16 +1617,16 @@ class stock_move(osv.osv):
ctx.update({'raise-exception': True})
uom_obj = self.pool.get('product.uom')
product_obj = self.pool.get('product.product')
- product_uom = product_obj.browse(cr, uid, product_id).uom_id
- prodlot = self.pool.get('stock.production.lot').browse(cr, uid, prodlot_id, ctx)
- location = self.pool.get('stock.location').browse(cr, uid, loc_id)
- uom = uom_obj.browse(cr, uid, uom_id, ctx)
- amount = uom_obj._compute_qty_obj(cr, uid, product_uom, product_qty, uom, ctx)
+ product_uom = product_obj.browse(cr, uid, product_id, context=ctx).uom_id
+ prodlot = self.pool.get('stock.production.lot').browse(cr, uid, prodlot_id, context=ctx)
+ location = self.pool.get('stock.location').browse(cr, uid, loc_id, context=ctx)
+ uom = uom_obj.browse(cr, uid, uom_id, context=ctx)
+ amount_actual = uom_obj._compute_qty_obj(cr, uid, product_uom, prodlot.stock_available, uom, context=ctx)
warning = {}
- if (location.usage == 'internal') and (product_qty > (prodlot.stock_available or 0.0)):
+ if (location.usage == 'internal') and (product_qty > (amount_actual or 0.0)):
warning = {
'title': _('Insufficient Stock in Lot !'),
- 'message': _('You are moving %.2f %s products but only %.2f %s available in this lot.') % (product_qty, uom.name, prodlot.stock_available or 0.0, uom.name)
+ 'message': _('You are moving %.2f %s products but only %.2f %s available in this lot.') % (product_qty, uom.name, amount_actual, uom.name)
}
return {'warning': warning}
@@ -2272,6 +2272,8 @@ class stock_move(osv.osv):
res = []
for move in self.browse(cr, uid, ids, context=context):
move_qty = move.product_qty
+ if move_qty <= 0:
+ raise osv.except_osv(_('Error!'), _('Can not consume a move with negative or zero quantity !'))
quantity_rest = move.product_qty
quantity_rest -= quantity
diff --git a/addons/stock/stock_view.xml b/addons/stock/stock_view.xml
index dfaba5c4494..24da71da743 100644
--- a/addons/stock/stock_view.xml
+++ b/addons/stock/stock_view.xml
@@ -723,7 +723,7 @@
<field name="prodlot_id" groups="base.group_extended"
context="{'location_id':location_id, 'product_id':product_id}"
domain="[('product_id','=?',product_id)]"
- on_change="onchange_lot_id(prodlot_id,product_qty, location_id, product_id)" colspan="3"/>
+ on_change="onchange_lot_id(prodlot_id,product_qty, location_id, product_id, product_uom)" colspan="3"/>
<button name="%(track_line)d"
groups="base.group_extended"
states="draft,waiting,confirmed,assigned"
@@ -1136,7 +1136,7 @@
<field name="prodlot_id" groups="base.group_extended"
context="{'location_id':location_id, 'product_id':product_id}"
domain="[('product_id','=?',product_id)]"
- on_change="onchange_lot_id(prodlot_id,product_qty, location_id, product_id)" colspan="3"/>
+ on_change="onchange_lot_id(prodlot_id,product_qty, location_id, product_id, product_uom)" colspan="3"/>
<button name="%(track_line)d"
groups="base.group_extended"
states="draft,waiting,confirmed,assigned"
@@ -1404,7 +1404,7 @@
<field name="prodlot_id" groups="base.group_extended"
context="{'location_id':location_id, 'product_id':product_id}"
domain="[('product_id','=?',product_id)]"
- on_change="onchange_lot_id(prodlot_id,product_qty, location_id, product_id)" colspan="3"/>
+ on_change="onchange_lot_id(prodlot_id,product_qty, location_id, product_id, product_uom)" colspan="3"/>
<button name="%(track_line)d"
groups="base.group_extended"
states="draft,waiting,confirmed,assigned"
@@ -1600,7 +1600,7 @@
<field name="prodlot_id" groups="base.group_extended"
context="{'location_id':location_id, 'product_id':product_id}"
domain="[('product_id','=?',product_id)]"
- on_change="onchange_lot_id(prodlot_id,product_qty, location_id, product_id)" colspan="3"/>
+ on_change="onchange_lot_id(prodlot_id,product_qty, location_id, product_id, product_uom)" colspan="3"/>
<button name="%(track_line)d"
groups="base.group_extended"
states="draft,waiting,confirmed,assigned,done"