[FIX] purchase: create suppier invoice based on incomming shipment + [FIX] stock_complex_route: fixed yaml test
bzr revid: qdp-launchpad@openerp.com-20131021095544-i0n6fd8jz31jo1l6
This commit is contained in:
@@ -38,19 +38,35 @@ class stock_move(osv.osv):
|
||||
workflow.trg_trigger(uid, 'stock.move', id, cr)
|
||||
return res
|
||||
|
||||
#
|
||||
# Inherit of picking to add the link to the PO
|
||||
#
|
||||
class stock_picking(osv.osv):
|
||||
_inherit = 'stock.picking'
|
||||
|
||||
def _get_to_invoice(self, cr, uid, ids, name, args, context=None):
|
||||
res = {}
|
||||
for picking in self.browse(cr, uid, ids, context=context):
|
||||
res[picking.id] = False
|
||||
for move in picking.move_lines:
|
||||
if move.purchase_line_id and move.purchase_line_id.order_id.invoice_method == 'picking':
|
||||
if not move.move_orig_ids:
|
||||
res[picking.id] = True
|
||||
return res
|
||||
|
||||
def _get_picking_to_recompute(self, cr, uid, ids, context=None):
|
||||
picking_ids = set()
|
||||
for move in self.pool.get('stock.move').browse(cr, uid, ids, context=context):
|
||||
if move.picking_id:
|
||||
picking_ids.add(move.picking_id.id)
|
||||
return list(picking_ids)
|
||||
|
||||
_columns = {
|
||||
'purchase_id': fields.many2one('purchase.order', 'Purchase Order',
|
||||
ondelete='set null', select=True),
|
||||
'reception_to_invoice': fields.function(_get_to_invoice, type='boolean', string='Invoiceable on incoming shipment?',
|
||||
help='Does the picking contains some moves related to a purchase order invoiceable on the reception?',
|
||||
store={
|
||||
'stock.picking': (lambda self, cr, uid, ids, c={}: ids, ['move_lines'], 10),
|
||||
'stock.move': (_get_picking_to_recompute, ['purchase_line_id', 'picking_id'], 10),
|
||||
}),
|
||||
}
|
||||
|
||||
_defaults = {
|
||||
'purchase_id': False,
|
||||
}
|
||||
|
||||
# TODO: Invoice based on receptions
|
||||
# Here is how it should work:
|
||||
|
||||
@@ -12,24 +12,13 @@
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="stock_picking_in_inherit_purchase" model="ir.ui.view">
|
||||
<field name="name">Picking Inherited</field>
|
||||
<field name="model">stock.picking</field>
|
||||
<field name="inherit_id" ref="stock.view_picking_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//field[@name='move_type']" position="before">
|
||||
<field name="purchase_id" domain="[('invoice_method','=','picking')]" groups="base.group_no_one" context="{'search_default_partner_id':partner_id,'default_partner_id':partner_id, 'default_invoice_method':'picking'}"/>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="view_picking_in_search_picking_inherit" model="ir.ui.view">
|
||||
<field name="name">stock.picking.in.search.inherit</field>
|
||||
<field name="model">stock.picking</field>
|
||||
<field name="inherit_id" ref="stock.view_picking_internal_search"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//field[@name='product_id']" position="before">
|
||||
<field name="purchase_id"/>
|
||||
<filter name="reception_to_invoice" string="Incoming Shipments to Invoice" domain="[('reception_to_invoice', '=', True)]"/>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
@@ -58,8 +47,7 @@
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,form,calendar</field>
|
||||
<field name="domain">[('purchase_id.invoice_method','=','picking')]</field>
|
||||
<field name="context">{"default_type": "in", "contact_display": "partner_address", "search_default_done": 1, "search_default_to_invoice": 1}</field>
|
||||
<field name="context">{"default_type": "in", "contact_display": "partner_address", "search_default_done": 1, "search_default_reception_to_invoice": 1}</field>
|
||||
<field name="search_view_id" ref="stock.view_picking_internal_search"/>
|
||||
<field name="help" type="html">
|
||||
<p class="oe_view_nocontent_create">
|
||||
|
||||
@@ -1310,7 +1310,7 @@ class stock_move(osv.osv):
|
||||
'move_dest_id': fields.many2one('stock.move', 'Destination Move', help="Optional: next stock move when chaining them", select=True),
|
||||
'move_orig_ids': fields.one2many('stock.move', 'move_dest_id', 'Original Move', help="Optional: previous stock move when chaining them", select=True),
|
||||
|
||||
'picking_id': fields.many2one('stock.picking', 'Reference', select=True,states={'done': [('readonly', True)]}),
|
||||
'picking_id': fields.many2one('stock.picking', 'Reference', select=True, states={'done': [('readonly', True)]}),
|
||||
'picking_priority': fields.related('picking_id','priority', type='selection', selection=[('0','Low'),('1','Normal'),('2','High')], string='Picking Priority'),
|
||||
'note': fields.text('Notes'),
|
||||
'state': fields.selection([('draft', 'New'),
|
||||
|
||||
@@ -71,8 +71,9 @@
|
||||
-
|
||||
!python {model: stock.picking}: |
|
||||
po_id = self.pool.get('purchase.order').search(cr, uid, [('partner_id', '=', ref('supplier_dropship'))])
|
||||
picking_id = self.search(cr, uid, [('purchase_id', '=', po_id[0])])
|
||||
self.do_partial(cr, uid, picking_id)
|
||||
assert po_id and len(po_id) == 1, 'Problem with the Purchase Order detected'
|
||||
picking_ids = [pick.id for pick in self.pool.get('purchase.order').browse(cr, uid, po_id[0]).picking_ids]
|
||||
self.do_partial(cr, uid, picking_ids)
|
||||
-
|
||||
Check one quant was created in Customers location with 200 pieces and one move in the history_ids
|
||||
-
|
||||
|
||||
Reference in New Issue
Block a user