[IMP] cleaning in progress: invoice on picking
bzr revid: fp@openerp.com-20130804134014-0xrkwlzhd6zfd6em
This commit is contained in:
parent
c522a3d440
commit
16cb4f8b2a
|
@ -761,7 +761,7 @@ class sale_order_line(osv.osv):
|
|||
'salesman_id':fields.related('order_id', 'user_id', type='many2one', relation='res.users', store=True, string='Salesperson'),
|
||||
'company_id': fields.related('order_id', 'company_id', type='many2one', relation='res.company', string='Company', store=True, readonly=True),
|
||||
'delay': fields.float('Delivery Lead Time', required=True, help="Number of days between the order confirmation and the shipping of the products to the customer", readonly=True, states={'draft': [('readonly', False)]}),
|
||||
'procurement_ids': fields.many2one('procurement.order', 'sale_line_ids', 'Procurements'),
|
||||
'procurement_ids': fields.one2many('procurement.order', 'sale_line_id', 'Procurements'),
|
||||
}
|
||||
_order = 'order_id desc, sequence, id'
|
||||
_defaults = {
|
||||
|
@ -1072,7 +1072,7 @@ class account_invoice(osv.Model):
|
|||
class procurement_order(osv.osv):
|
||||
_inherit = 'procurement.order'
|
||||
_columns = {
|
||||
'sale_line_id': fields.many2one('sale.order.line', string = 'Sale Order Line')
|
||||
'sale_line_id': fields.many2one('sale.order.line', string='Sale Order Line'),
|
||||
'invoice_state': fields.selection(
|
||||
[
|
||||
("invoiced", "Invoiced"),
|
||||
|
@ -1084,5 +1084,3 @@ class procurement_order(osv.osv):
|
|||
'invoice_state': 'none',
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -24,4 +24,5 @@ import stock
|
|||
import report
|
||||
import company
|
||||
import res_config
|
||||
import wizard
|
||||
|
||||
|
|
|
@ -47,21 +47,24 @@ You can choose flexible invoicing methods:
|
|||
'images': ['images/deliveries_to_invoice.jpeg'],
|
||||
'depends': ['sale', 'stock_account'],
|
||||
'init_xml': [],
|
||||
'update_xml': ['security/sale_stock_security.xml',
|
||||
'security/ir.model.access.csv',
|
||||
'company_view.xml',
|
||||
'sale_stock_view.xml',
|
||||
'sale_stock_workflow.xml',
|
||||
'stock_view.xml',
|
||||
'res_config_view.xml',
|
||||
'report/sale_report_view.xml',
|
||||
],
|
||||
'update_xml': [
|
||||
'security/sale_stock_security.xml',
|
||||
'security/ir.model.access.csv',
|
||||
'company_view.xml',
|
||||
'wizard/stock_invoice_onshipping_view.xml',
|
||||
'sale_stock_view.xml',
|
||||
'sale_stock_workflow.xml',
|
||||
'stock_view.xml',
|
||||
'res_config_view.xml',
|
||||
'report/sale_report_view.xml',
|
||||
],
|
||||
'demo_xml': ['sale_stock_demo.xml'],
|
||||
'test': ['test/cancel_order_sale_stock.yml',
|
||||
'test/picking_order_policy.yml',
|
||||
'test/prepaid_order_policy.yml',
|
||||
'test/sale_order_onchange.yml',
|
||||
],
|
||||
'test': [
|
||||
'test/cancel_order_sale_stock.yml',
|
||||
'test/picking_order_policy.yml',
|
||||
'test/prepaid_order_policy.yml',
|
||||
'test/sale_order_onchange.yml',
|
||||
],
|
||||
'installable': True,
|
||||
'auto_install': True,
|
||||
}
|
||||
|
|
|
@ -57,11 +57,9 @@ class sale_order(osv.osv):
|
|||
|
||||
def _get_orders(self, cr, uid, ids, context=None):
|
||||
res = set()
|
||||
proc_obj = self.pool.get("procurement.order")
|
||||
procs = proc_obj.search(cr, uid, [('move_id', 'in', ids)], context=context)
|
||||
for proc in proc_obj.browse(cr, uid, procs, context=context):
|
||||
if proc.group_id and proc.group_id.sale_id:
|
||||
res.add(proc.group_id.sale_id.id)
|
||||
for move in self.browse(cr, uid, ids, context=context):
|
||||
if move.procurement_id and move.procurement_id.sale_line_id:
|
||||
res.add(move.procurement_id.sale_line_id.order_id.id)
|
||||
return list(res)
|
||||
|
||||
def _get_picking_ids(self, cr, uid, ids, name, args, context=None):
|
||||
|
@ -72,8 +70,9 @@ class sale_order(osv.osv):
|
|||
continue
|
||||
picking_ids = {}
|
||||
for procurement in sale.procurement_group_id.procurement_ids:
|
||||
if procurement.move_id and procurement.move_id.picking_id:
|
||||
picking_ids[procurement.move_id.picking_id.id] = True
|
||||
for move in procurement.move_ids:
|
||||
if move.picking_id:
|
||||
picking_ids[move.picking_id.id] = True
|
||||
res[sale.id] = picking_ids.keys()
|
||||
return res
|
||||
|
||||
|
@ -207,13 +206,12 @@ class sale_order(osv.osv):
|
|||
write_cancel_ids = []
|
||||
for order in self.browse(cr, uid, ids, context={}):
|
||||
for line in order.order_line:
|
||||
if (not line.procurement_id) or (line.procurement_id.state=='done'):
|
||||
if line.state != 'done':
|
||||
for procurement in line.procurement_ids:
|
||||
if procurement.state != 'done':
|
||||
write_done_ids.append(line.id)
|
||||
else:
|
||||
finished = False
|
||||
if line.procurement_id:
|
||||
if (line.procurement_id.state == 'cancel'):
|
||||
else:
|
||||
finished = False
|
||||
if (procurement.state == 'cancel'):
|
||||
canceled = True
|
||||
if line.state != 'exception':
|
||||
write_cancel_ids.append(line.id)
|
||||
|
|
|
@ -58,10 +58,6 @@
|
|||
<xpath expr="//page[@string='Order Lines']/field[@name='order_line']/form[@string='Sales Order Lines']/group/group/field[@name='tax_id']" position="before">
|
||||
<field name="product_packaging" context="{'partner_id':parent.partner_id, 'quantity':product_uom_qty, 'pricelist':parent.pricelist_id, 'uom':product_uom}" on_change="product_packaging_change(parent.pricelist_id, product_id, product_uom_qty, product_uom, parent.partner_id, product_packaging, True, context)" domain="[('product_id','=',product_id)]" groups="product.group_stock_packaging" />
|
||||
</xpath>
|
||||
<xpath expr="//page[@string='Order Lines']/field[@name='order_line']/form[@string='Sales Order Lines']/div/field[@name='invoice_lines']" position="after">
|
||||
<label for="move_ids"/>
|
||||
<field name="move_ids" widget="many2many"/>
|
||||
</xpath>
|
||||
<xpath expr="//page[@string='Order Lines']/field[@name='order_line']/tree[@string='Sales Order Lines']/field[@name='sequence']" position="after">
|
||||
<field name="delay" invisible="1"/>
|
||||
</xpath>
|
||||
|
@ -108,5 +104,29 @@
|
|||
groups="sale.group_delivery_invoice_address"
|
||||
/>
|
||||
|
||||
<record id="view_picking_inherit_form2" model="ir.ui.view">
|
||||
<field name="name">stock.picking.form.inherit</field>
|
||||
<field name="model">stock.picking</field>
|
||||
<field name="inherit_id" ref="stock.view_picking_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//button[@name='do_prepare_partial']" position="after">
|
||||
<button name="%(action_stock_invoice_onshipping)d" string="Create Invoice/Refund" attrs="{'invisible': ['|','|',('state','<>','done'),('invoice_state','=','invoiced'),('invoice_state','=','none')]}" type="action" class="oe_highlight" groups="base.group_user"/>
|
||||
<field name="invoice_state" string="Invoice Control" groups="account.group_account_invoice" attrs="{'invisible':[('invoice_state', '=', 'none')]}"/>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="view_picking_internal_search_inherit" model="ir.ui.view">
|
||||
<field name="name">stock.picking.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='partner_id']" position="before">
|
||||
<filter string="To Invoice" name="to_invoice" icon="terp-dolar" domain="[('invoice_state', '=', '2binvoiced')]"/>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
|
|
|
@ -24,7 +24,7 @@ from openerp.tools.translate import _
|
|||
|
||||
class stock_picking(osv.osv):
|
||||
_inherit = 'stock.picking'
|
||||
def __get_invoice_state(self, cursor, user, ids, name, arg, context=None):
|
||||
def __get_invoice_state(self, cr, uid, ids, name, arg, context=None):
|
||||
result = {}
|
||||
for pick in self.browse(cr, uid, ids, context=context):
|
||||
result[pick.id] = 'none'
|
||||
|
@ -37,14 +37,25 @@ class stock_picking(osv.osv):
|
|||
break
|
||||
return result
|
||||
|
||||
def __get_picking_procurement(self, cr, uid, ids, context={}):
|
||||
result = {}
|
||||
for proc in self.pool.get('procurement.order').browse(cr, uid, ids, context=context):
|
||||
for move in proc.move_ids:
|
||||
if move.picking_id:
|
||||
result[move.picking_id.id] = True
|
||||
return result.keys()
|
||||
|
||||
_columns = {
|
||||
# TODO: add a store=...
|
||||
'invoice_state': fields.function(_get_invoice_state, type='selection', selection=[
|
||||
'invoice_state': fields.function(__get_invoice_state, type='selection', selection=[
|
||||
("invoiced", "Invoiced"),
|
||||
("2binvoiced", "To Be Invoiced"),
|
||||
("none", "Not Applicable")
|
||||
], "Invoice Control", required=True),
|
||||
|
||||
], string="Invoice Control", required=True,
|
||||
store={'procurement.order': (__get_picking_procurement, ['invoice_state'], 10)},
|
||||
),
|
||||
}
|
||||
_defaults = {
|
||||
'invoice_state': lambda *args, **argv: 'none'
|
||||
}
|
||||
|
||||
def action_invoice_create(self, cr, uid, ids, journal_id=False, group=False, type='out_invoice', context=None):
|
||||
|
@ -88,14 +99,14 @@ class stock_picking(osv.osv):
|
|||
invoice_id = self.pool.get('account.invoice').create(cr, uid, {
|
||||
'origin': sale.name,
|
||||
'date_invoice': context.get('date_inv', False),
|
||||
'user_id': sale.user_id and sale.user_id.id or False
|
||||
'user_id': sale.user_id and sale.user_id.id or False,
|
||||
'partner_id': partner.id,
|
||||
'account_id': account_id,
|
||||
'payment_term': payment_term,
|
||||
'type': inv_type,
|
||||
'fiscal_position': partner.property_account_position.id,
|
||||
'company_id': sale.company_id.id,
|
||||
'currency_id': sale.pricelist_id.currency_id.id,
|
||||
'currency_id': sale.pricelist_id.currency_id.id,
|
||||
'journal_id': journal_id,
|
||||
}, context=context)
|
||||
invoices[key] = invoice_id
|
||||
|
|
|
@ -2,19 +2,6 @@
|
|||
<openerp>
|
||||
<data>
|
||||
|
||||
<!-- Adding Sales Order Reference to outgoing picking -->
|
||||
|
||||
<record id="stock_picking_out_inherit_sale" model="ir.ui.view">
|
||||
<field name="name">Outgoing picking Inherited</field>
|
||||
<field name="model">stock.picking</field>
|
||||
<field name="inherit_id" ref="stock.view_picking_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="move_type" position="after">
|
||||
<field name="sale_id"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- Add menu: Billing - Deliveries to invoice -->
|
||||
<record id="outgoing_picking_list_to_invoice" model="ir.actions.act_window">
|
||||
<field name="name">Deliveries to Invoice</field>
|
||||
|
@ -23,7 +10,7 @@
|
|||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,form,calendar</field>
|
||||
<field name="domain">[('location_id.usage','=','internal'), ('location_dest_id.usage','!=','internal')]</field>
|
||||
<field name="context">{'default_type': 'out', 'contact_display': 'partner_address', 'search_default_to_invoice': 1, 'search_default_done': 1, 'default_invoice_state': '2binvoiced'}</field>
|
||||
<field name="context">{'default_type': 'out', 'contact_display': 'partner_address', 'search_default_to_invoice': 1, 'search_default_done': 1}</field>
|
||||
<field name="search_view_id" ref="stock.view_picking_internal_search"/>
|
||||
</record>
|
||||
<menuitem action="outgoing_picking_list_to_invoice" id="menu_action_picking_list_to_invoice" parent="base.menu_invoiced" groups="sale_stock.group_invoice_deli_orders" sequence="20"/>
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
# published by the Free Software Foundation, either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# 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/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
import stock_invoice_onshipping
|
|
@ -39,7 +39,7 @@ class procurement_rule(osv.osv):
|
|||
_columns = {
|
||||
'location_id': fields.many2one('stock.location', 'Destination Location'),
|
||||
'location_src_id': fields.many2one('stock.location', 'Source Location',
|
||||
help="Source location is action=move"),
|
||||
help="Source location is action=move"),
|
||||
'picking_type_id': fields.many2one('stock.picking.type', 'Picking Type', required=True,
|
||||
help="Picking Type determines the way the picking should be shown in the view, reports, ...")
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ class procurement_order(osv.osv):
|
|||
_inherit = "procurement.order"
|
||||
_columns = {
|
||||
'location_id': fields.many2one('stock.location', 'Destination Location'),
|
||||
'move_id': fields.many2one('stock.move', 'Move', help="Move created by the procurement"),
|
||||
'move_ids': fields.one2many('stock.move', 'procurement_id', 'Moves', help="Moves created by the procurement"),
|
||||
'move_dest_id': fields.many2one('stock.move', 'Destination Move', help="Move which caused (created) the procurement"),
|
||||
}
|
||||
|
||||
|
@ -82,7 +82,7 @@ class procurement_order(osv.osv):
|
|||
'location_id': procurement.rule_id.location_src_id.id,
|
||||
'location_dest_id': procurement.rule_id.location_id.id,
|
||||
'move_dest_id': procurement.move_dest_id and procurement.move_dest_id.id or False,
|
||||
'group_id': procurement.group_id and procurement.group_id.id or False,
|
||||
'procurement_id': procurement.id,
|
||||
'rule_id': procurement.rule_id.id,
|
||||
'picking_type_id': procurement.rule_id.picking_type_id.id,
|
||||
}
|
||||
|
@ -96,12 +96,16 @@ class procurement_order(osv.osv):
|
|||
move_dict = self._run_move_create(cr, uid, procurement, context=context)
|
||||
move_id = move_obj.create(cr, uid, move_dict, context=context)
|
||||
move_obj.action_confirm(cr, uid, [move_id], context=context)
|
||||
self.write(cr, uid, [procurement.id], {'move_id': move_id}, context=context)
|
||||
return move_id
|
||||
return super(procurement_order, self)._run(cr, uid, procurement, context)
|
||||
|
||||
def _check(self, cr, uid, procurement, context=None):
|
||||
if procurement.rule_id and procurement.rule_id.action == 'move':
|
||||
for move in procurement.move_ids:
|
||||
if not move.state in ('done', 'cancel'):
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
return procurement.move_id.state == 'done'
|
||||
return super(procurement_order, self)._check(cr, uid, procurement, context)
|
||||
|
||||
|
|
|
@ -951,7 +951,8 @@ class stock_move(osv.osv):
|
|||
'quant_ids': fields.many2many('stock.quant', 'stock_quant_move_rel', 'move_id', 'quant_id', 'Quants'),
|
||||
'reserved_quant_ids': fields.one2many('stock.quant', 'reservation_id', 'Reserved quants'),
|
||||
'remaining_qty': fields.function(_get_remaining_qty, type='float', string='Remaining Quantity', digits_compute=dp.get_precision('Product Unit of Measure'), states={'done': [('readonly', True)]}),
|
||||
'group_id': fields.many2one('procurement.group', 'Procurement Group'),
|
||||
'procurement_id': fields.many2one('procurement.order', 'Procurement'),
|
||||
'group_id': fields.related('procurement_id', 'group_id', type='many2one', relation="procurement.group", string='Procurement Group'),
|
||||
'rule_id': fields.many2one('procurement.rule', 'Procurement Rule'),
|
||||
'propagate': fields.boolean('Propagate cancel and split', help='If checked, when this move is cancelled, cancel the linked move too'),
|
||||
'picking_type_id': fields.many2one('stock.picking.type', 'Picking Type'),
|
||||
|
@ -2136,4 +2137,3 @@ class stock_picking_type(osv.osv):
|
|||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -48,11 +48,9 @@ Dashboard / Reports for Warehouse Management will include:
|
|||
],
|
||||
'data': [
|
||||
'stock_account_data.xml',
|
||||
'wizard/stock_invoice_onshipping_view.xml',
|
||||
'wizard/stock_change_standard_price_view.xml',
|
||||
'product_data.xml',
|
||||
'product_view.xml',
|
||||
|
||||
'stock_account_view.xml',
|
||||
'valuationandcostmethod.yml',
|
||||
],
|
||||
|
|
|
@ -16,28 +16,5 @@
|
|||
</field>
|
||||
</record>
|
||||
|
||||
<record id="view_picking_inherit_form2" model="ir.ui.view">
|
||||
<field name="name">stock.picking.form.inherit</field>
|
||||
<field name="model">stock.picking</field>
|
||||
<field name="inherit_id" ref="stock.view_picking_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//button[@name='action_process']" position="after">
|
||||
<button name="%(action_stock_invoice_onshipping)d" string="Create Invoice/Refund" attrs="{'invisible': ['|','|',('state','<>','done'),('invoice_state','=','invoiced'),('invoice_state','=','none')]}" type="action" class="oe_highlight" groups="base.group_user"/>
|
||||
<field name="invoice_state" string="Invoice Control" groups="account.group_account_invoice" attrs="{'invisible':[('invoice_state', '=', 'none')]}"/>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="view_picking_internal_search_inherit" model="ir.ui.view">
|
||||
<field name="name">stock.picking.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='partner_id']" position="before">
|
||||
<filter string="To Invoice" name="to_invoice" icon="terp-dolar" domain="[('invoice_state', '=', '2binvoiced')]"/>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
|
|
|
@ -20,4 +20,3 @@
|
|||
##############################################################################
|
||||
|
||||
import stock_change_standard_price
|
||||
import stock_invoice_onshipping
|
||||
|
|
Loading…
Reference in New Issue