[Fix]: Invoice from Picking not updating the status of the Purchase Order
lp bug: https://launchpad.net/bugs/697089 fixed bzr revid: rha@tinyerp.com-20110107044230-dje9lzmt83ueksah
This commit is contained in:
@@ -817,4 +817,20 @@ class procurement_order(osv.osv):
|
||||
|
||||
procurement_order()
|
||||
|
||||
class stock_invoice_onshipping(osv.osv_memory):
|
||||
_inherit = "stock.invoice.onshipping"
|
||||
|
||||
def create_invoice(self, cr, uid, ids, context=None):
|
||||
if context is None:
|
||||
context = {}
|
||||
purchase_obj = self.pool.get('purchase.order')
|
||||
picking_obj = self.pool.get('stock.picking')
|
||||
res = super(stock_invoice_onshipping,self).create_invoice(cr, uid, ids, context=context)
|
||||
purchase_id = picking_obj.browse(cr, uid, res.keys()[0]).purchase_id.id
|
||||
purchase_obj.write(cr, uid, [purchase_id], {
|
||||
'invoice_ids': [(4, res.values()[0])]}, context=context)
|
||||
return res
|
||||
|
||||
stock_invoice_onshipping()
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
@@ -12,10 +12,10 @@
|
||||
groups="group_purchase_manager"
|
||||
parent="base.menu_purchase_root" sequence="100"/>
|
||||
|
||||
<menuitem
|
||||
<menuitem
|
||||
id="menu_purchase_config_pricelist" name="Pricelists"
|
||||
parent="menu_purchase_config_purchase" sequence="50"/>
|
||||
|
||||
|
||||
<menuitem
|
||||
action="product.product_pricelist_action" id="menu_product_pricelist_action_purhase"
|
||||
parent="menu_purchase_config_pricelist" sequence="20"/>
|
||||
@@ -29,22 +29,22 @@
|
||||
parent="menu_purchase_config_pricelist" sequence="2"
|
||||
groups="base.group_extended"/>
|
||||
|
||||
<menuitem
|
||||
<menuitem
|
||||
id="menu_product_in_config_purchase" name="Product"
|
||||
parent="menu_purchase_config_purchase" sequence="30"/>
|
||||
|
||||
|
||||
<menuitem
|
||||
action="product.product_category_action_form" id="menu_product_category_config_purchase"
|
||||
parent="purchase.menu_product_in_config_purchase" sequence="10"/>
|
||||
|
||||
<menuitem
|
||||
|
||||
<menuitem
|
||||
id="menu_purchase_unit_measure_purchase" name="Units of Measure"
|
||||
parent="purchase.menu_product_in_config_purchase" sequence="20"/>
|
||||
|
||||
|
||||
<menuitem
|
||||
action="product.product_uom_categ_form_action" id="menu_purchase_uom_categ_form_action"
|
||||
parent="menu_purchase_unit_measure_purchase" sequence="30"/>
|
||||
|
||||
|
||||
<menuitem
|
||||
action="product.product_uom_form_action" id="menu_purchase_uom_form_action"
|
||||
parent="menu_purchase_unit_measure_purchase" sequence="30"/>
|
||||
@@ -113,10 +113,10 @@
|
||||
<!--product menu-->
|
||||
<menuitem id="menu_procurement_management_product" name="Products"
|
||||
parent="base.menu_purchase_root" sequence="8"/>
|
||||
|
||||
|
||||
<menuitem name="Products by Category" id="menu_product_by_category_purchase_form" action="product.product_category_action"
|
||||
parent="menu_procurement_management_product" sequence="10"/>
|
||||
|
||||
|
||||
<menuitem name="Products" id="menu_procurement_partner_contact_form" action="product.product_normal_action_puchased"
|
||||
parent="menu_procurement_management_product"/>
|
||||
|
||||
@@ -292,7 +292,7 @@
|
||||
<field name="search_view_id" ref="view_purchase_order_filter"/>
|
||||
<field name="help">You can create a request for quotation when you want to buy products to a supplier but the purchase is not confirmed yet. Use also this menu to review requests for quotation created automatically based on your logistic rules (minimum stock, MTO, etc). You can convert the request for quotation into a purchase order once the order is confirmed. If you use the extended interface (from user's preferences), you can select the way to control your supplier invoices: based on the order, based on the receptions or manual encoding.</field>
|
||||
</record>
|
||||
<menuitem action="purchase_rfq" id="menu_purchase_rfq"
|
||||
<menuitem action="purchase_rfq" id="menu_purchase_rfq"
|
||||
parent="menu_procurement_management"
|
||||
sequence="6"/>
|
||||
|
||||
@@ -458,7 +458,7 @@
|
||||
<field name="name">Purchase Lines Not Invoiced</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">purchase.order.line</field>
|
||||
<field name="domain">[('state','in',('confirmed','done')), ('invoiced', '=', False)]</field>
|
||||
<field name="domain">[('order_id.invoice_method','<>','picking'), ('state','in',('confirmed','done')), ('invoiced', '=', False)]</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
<field name="search_view_id" ref="purchase_order_line_search"/>
|
||||
|
||||
@@ -85,34 +85,18 @@ class stock_invoice_onshipping(osv.osv_memory):
|
||||
raise osv.except_osv(_('Warning !'), _('None of these picking lists require invoicing.'))
|
||||
return res
|
||||
|
||||
|
||||
|
||||
def create_invoice(self, cr, uid, ids, context=None):
|
||||
def open_invoice(self, cr, uid, ids, context=None):
|
||||
if context is None:
|
||||
context = {}
|
||||
picking_pool = self.pool.get('stock.picking')
|
||||
data_pool = self.pool.get('ir.model.data')
|
||||
onshipdata_obj = self.read(cr, uid, ids[0], ['journal_id', 'group', 'invoice_date'])
|
||||
if context.get('new_picking', False):
|
||||
onshipdata_obj['id'] = onshipdata_obj.new_picking
|
||||
onshipdata_obj[ids] = onshipdata_obj.new_picking
|
||||
|
||||
context['date_inv'] = onshipdata_obj['invoice_date']
|
||||
invoice_ids = []
|
||||
active_ids = context.get('active_ids', [])
|
||||
active_picking = picking_pool.browse(cr, uid, context.get('active_id',False), context=context)
|
||||
inv_type = picking_pool._get_invoice_type(active_picking)
|
||||
|
||||
res = picking_pool.action_invoice_create(cr, uid, active_ids,
|
||||
journal_id = onshipdata_obj['journal_id'],
|
||||
group = onshipdata_obj['group'],
|
||||
type = None,
|
||||
context=context)
|
||||
data_pool = self.pool.get('ir.model.data')
|
||||
res = self.create_invoice(cr, uid, ids, context=context)
|
||||
invoice_ids += res.values()
|
||||
if not invoice_ids:
|
||||
raise osv.except_osv(_('Error'), _('No Invoices were created'))
|
||||
inv_type = context.get('inv_type', False)
|
||||
action_model = False
|
||||
action = {}
|
||||
if not invoice_ids:
|
||||
raise osv.except_osv(_('Error'), _('No Invoices were created'))
|
||||
if inv_type == "out_invoice":
|
||||
action_model,action_id = data_pool.get_object_reference(cr, uid, 'account', "action_invoice_tree1")
|
||||
elif inv_type == "in_invoice":
|
||||
@@ -127,6 +111,26 @@ class stock_invoice_onshipping(osv.osv_memory):
|
||||
action['domain'] = "[('id','in', ["+','.join(map(str,invoice_ids))+"])]"
|
||||
return action
|
||||
|
||||
def create_invoice(self, cr, uid, ids, context=None):
|
||||
if context is None:
|
||||
context = {}
|
||||
picking_pool = self.pool.get('stock.picking')
|
||||
onshipdata_obj = self.read(cr, uid, ids, ['journal_id', 'group', 'invoice_date'])
|
||||
if context.get('new_picking', False):
|
||||
onshipdata_obj['id'] = onshipdata_obj.new_picking
|
||||
onshipdata_obj[ids] = onshipdata_obj.new_picking
|
||||
context['date_inv'] = onshipdata_obj[0]['invoice_date']
|
||||
active_ids = context.get('active_ids', [])
|
||||
active_picking = picking_pool.browse(cr, uid, context.get('active_id',False), context=context)
|
||||
inv_type = picking_pool._get_invoice_type(active_picking)
|
||||
context['inv_type'] = inv_type
|
||||
res = picking_pool.action_invoice_create(cr, uid, active_ids,
|
||||
journal_id = onshipdata_obj[0]['journal_id'],
|
||||
group = onshipdata_obj[0]['group'],
|
||||
type = None,
|
||||
context=context)
|
||||
return res
|
||||
|
||||
stock_invoice_onshipping()
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
<field name="invoice_date" />
|
||||
<separator string="" colspan="4" />
|
||||
<button special="cancel" string="_Cancel" icon='gtk-cancel'/>
|
||||
<button name="create_invoice" string="Create" type="object" icon="terp-gtk-go-back-rtl"/>
|
||||
<button name="open_invoice" string="Create" type="object" icon="terp-gtk-go-back-rtl"/>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
Reference in New Issue
Block a user