[MREGE]: Merge with lp:~openerp-commiter/openobject-addons/dev-addons2-rha1

bzr revid: rpa@tinyerp.com-20101220130056-jtt8okpeabhz28bv
This commit is contained in:
rpa (Open ERP) 2010-12-20 18:30:56 +05:30
commit b84488356c
9 changed files with 70 additions and 48 deletions

View File

@ -13,7 +13,7 @@
<menuitem name="Master Data"
id="menu_mrp_bom"
parent="base.menu_mrp_root"
groups="mrp.group_mrp_manager"
groups="mrp.group_mrp_manager,mrp.group_mrp_user"
sequence="5" />
<!--

View File

@ -70,4 +70,4 @@
"access_stock_picking_mrp_manager","stock.picking mrp_manager","stock.model_stock_picking","mrp.group_mrp_manager",1,0,0,0
"access_report_mrp_inout_user","report.mrp.inout user","model_report_mrp_inout","mrp.group_mrp_user",1,0,0,0
"access_report_workcenter_load_user","report.workcenter.load.user","model_report_workcenter_load","mrp.group_mrp_user",1,0,0,0
"access_mrp_bom","mrp.bom","model_mrp_bom","base.group_sale_salesman",1,0,0,0
"access_mrp_bom_salesman","mrp.bom","model_mrp_bom","base.group_sale_salesman",1,0,0,0

1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
70 access_stock_picking_mrp_manager stock.picking mrp_manager stock.model_stock_picking mrp.group_mrp_manager 1 0 0 0
71 access_report_mrp_inout_user report.mrp.inout user model_report_mrp_inout mrp.group_mrp_user 1 0 0 0
72 access_report_workcenter_load_user report.workcenter.load.user model_report_workcenter_load mrp.group_mrp_user 1 0 0 0
73 access_mrp_bom access_mrp_bom_salesman mrp.bom model_mrp_bom base.group_sale_salesman 1 0 0 0

View File

@ -93,7 +93,7 @@ class mrp_repair(osv.osv):
cur = repair.pricelist_id.currency_id
res[id] = cur_obj.round(cr, uid, cur, untax.get(id, 0.0) + tax.get(id, 0.0))
return res
def _get_default_address(self, cr, uid, ids, field_name, arg, context=None):
res = {}
partner_obj = self.pool.get('res.partner')
@ -222,7 +222,7 @@ class mrp_repair(osv.osv):
if move_id:
move = self.pool.get('stock.move').browse(cr, uid, move_id)
product = self.pool.get('product.product').browse(cr, uid, prod_id)
limit = datetime.strptime(move.date_expected, '%Y-%m-%d %H:%M:%S') + relativedelta(months=product.warranty)
limit = datetime.strptime(move.date_expected, '%Y-%m-%d %H:%M:%S') + relativedelta(months=int(product.warranty))
data['value']['guarantee_limit'] = limit.strftime('%Y-%m-%d')
data['value']['location_id'] = move.location_dest_id.id
data['value']['location_dest_id'] = move.location_dest_id.id
@ -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
@ -425,14 +425,14 @@ class mrp_repair(osv.osv):
name = fee.name
if not fee.product_id:
raise osv.except_osv(_('Warning !'), _('No product defined on Fees!'))
if fee.product_id.property_account_income:
account_id = fee.product_id.property_account_income.id
elif fee.product_id.categ_id.property_account_income_categ:
account_id = fee.product_id.categ_id.property_account_income_categ.id
else:
raise osv.except_osv(_('Error !'), _('No account defined for product "%s".') % fee.product_id.name)
invoice_fee_id = inv_line_obj.create(cr, uid, {
'invoice_id': inv_id,
'name': name,
@ -453,7 +453,10 @@ class mrp_repair(osv.osv):
""" Writes repair order state to 'Ready'
@return: True
"""
self.write(cr, uid, ids, {'state': 'ready'})
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'}, context=context)
self.write(cr, uid, [repair.id], {'state': 'ready'})
return True
def action_invoice_cancel(self, cr, uid, ids, context=None):
@ -467,20 +470,27 @@ class mrp_repair(osv.osv):
""" Writes repair order state to 'Under Repair'
@return: True
"""
self.write(cr, uid, ids, {'state': 'under_repair'})
repair_line = self.pool.get('mrp.repair.line')
for repair in self.browse(cr, uid, ids, context=context):
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'
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):
@ -527,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})
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, {

View File

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
##############################################################################
#
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
@ -15,7 +15,7 @@
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
@ -35,7 +35,7 @@ class mrp_subproduct(osv.osv):
_defaults={
'subproduct_type': lambda *args: 'fixed'
}
def onchange_product_id(self, cr, uid, ids, product_id, context=None):
""" Changes UoM if product_id changes.
@param product_id: Changed product_id
@ -53,7 +53,7 @@ class mrp_bom(osv.osv):
_name = 'mrp.bom'
_description = 'Bill of Material'
_inherit='mrp.bom'
_columns={
'sub_products':fields.one2many('mrp.subproduct', 'bom_id', 'sub_products'),
}
@ -62,7 +62,7 @@ mrp_bom()
class mrp_production(osv.osv):
_name = 'mrp.production'
_description = 'Production'
_inherit= 'mrp.production'
_inherit= 'mrp.production'
def action_confirm(self, cr, uid, ids):
""" Confirms production order and calculates quantity based on subproduct_type.

View File

@ -88,12 +88,14 @@ class purchase_order(osv.osv):
res[purchase.id]=min_date
return res
def _invoiced_rate(self, cursor, user, ids, name, arg, context=None):
res = {}
for purchase in self.browse(cursor, user, ids, context=context):
tot = 0.0
if purchase.invoice_id and purchase.invoice_id.state not in ('draft','cancel'):
tot += purchase.invoice_id.amount_untaxed
for invoice in purchase.invoice_ids:
if invoice.state not in ('draft','cancel'):
tot += invoice.amount_untaxed
if purchase.amount_untaxed:
res[purchase.id] = tot * 100.0 / purchase.amount_untaxed
else:
@ -137,10 +139,10 @@ 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):
if purchase.invoice_id.reconciled:
res[purchase.id] = purchase.invoice_id.reconciled
else:
res[purchase.id] = False
invoiced = False
if purchase.invoiced_rate == 100.00:
invoiced = True
res[purchase.id] = invoiced
return res
STATE_SELECTION = [
@ -177,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_id': fields.many2one('account.invoice', 'Invoice', readonly=True, help="An invoice 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'),
@ -375,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_id': inv_id})
self.write(cr, uid, [o.id], {'invoice_ids': [(4, inv_id)]})
res = inv_id
return res
@ -396,14 +398,14 @@ class purchase_order(osv.osv):
for pick in purchase.picking_ids:
wf_service = netsvc.LocalService("workflow")
wf_service.trg_validate(uid, 'stock.picking', pick.id, 'button_cancel', cr)
inv = purchase.invoice_id
if inv and inv.state not in ('cancel','draft'):
raise osv.except_osv(
_('Could not cancel this purchase order !'),
_('You must first cancel all invoices attached to this purchase order.'))
if inv:
wf_service = netsvc.LocalService("workflow")
wf_service.trg_validate(uid, 'account.invoice', inv.id, 'invoice_cancel', cr)
for inv in purchase.invoice_ids:
if inv and inv.state not in ('cancel','draft'):
raise osv.except_osv(
_('Could not cancel this purchase order !'),
_('You must first cancel all invoices attached to this purchase order.'))
if inv:
wf_service = netsvc.LocalService("workflow")
wf_service.trg_validate(uid, 'account.invoice', inv.id, 'invoice_cancel', cr)
self.write(cr,uid,ids,{'state':'cancel'})
for (id,name) in self.name_get(cr, uid, ids):
message = _("Purchase order '%s' is cancelled.") % name
@ -467,8 +469,8 @@ class purchase_order(osv.osv):
'state':'draft',
'shipped':False,
'invoiced':False,
'invoice_id':False,
'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)

View File

@ -174,13 +174,15 @@
<group colspan="2" col="2">
<separator string="Invoice Control" colspan="2"/>
<field name="invoice_method"/>
<field name="invoice_id" readonly="1" groups="base.group_extended" />
<field name="fiscal_position" widget="selection"/>
</group>
<newline/>
<separator string="Purchase Control" colspan="4"/>
<field name="validator"/>
<field name="date_approve"/>
<separator string="Invoices" colspan="4"/>
<newline/>
<field name="invoice_ids" groups="base.group_extended" nolabel="1" colspan="4"/>
</page>
<page string="Notes">
<field colspan="4" name="notes" nolabel="1"/>

View File

@ -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 = []

View File

@ -1602,7 +1602,7 @@ class stock_move(osv.osv):
return res
def onchange_lot_id(self, cr, uid, ids, prodlot_id=False, product_qty=False,
loc_id=False, product_id=False, context=None):
loc_id=False, product_id=False, uom_id=False, context=None):
""" On change of production lot gives a warning message.
@param prodlot_id: Changed production lot id
@param product_qty: Quantity of product
@ -1614,13 +1614,19 @@ class stock_move(osv.osv):
return {}
ctx = context and context.copy() or {}
ctx['location_id'] = loc_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)
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, 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 products but only %.2f available in this lot.') % (product_qty, prodlot.stock_available or 0.0)
'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}
@ -1675,7 +1681,7 @@ class stock_move(osv.osv):
result['product_qty'] = product_uos_qty
return {'value': result}
def onchange_product_id(self, cr, uid, ids, prod_id=False, loc_id=False,
loc_dest_id=False, address_id=False):
""" On change of product id, if finds UoM, UoS, quantity and UoS quantity.

View File

@ -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"
@ -916,7 +916,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"