[IMP] purchase: merge purchase and purchase_manual module and remove the purchase_manual

bzr revid: sbh@tinyerp.com-20100413102822-4nn560p3ffieoqs6
This commit is contained in:
sbh (Open ERP) 2010-04-13 15:58:22 +05:30
parent c8afb8bc27
commit 1deb0460e8
11 changed files with 82 additions and 280 deletions

View File

@ -42,6 +42,7 @@
'purchase_data.xml',
'wizard/purchase_order_group_view.xml',
'wizard/purchase_installer.xml',
'wizard/purchase_line_invoice_view.xml',
'purchase_view.xml',
'purchase_report.xml',
'stock_view.xml',

View File

@ -259,12 +259,18 @@ class purchase_order(osv.osv):
return True
def wkf_confirm_order(self, cr, uid, ids, context={}):
todo = []
for po in self.browse(cr, uid, ids):
if self.pool.get('res.partner.event.type').check(cr, uid, 'purchase_open'):
self.pool.get('res.partner.event').create(cr, uid, {'name':'Purchase Order: '+po.name, 'partner_id':po.partner_id.id, 'date':time.strftime('%Y-%m-%d %H:%M:%S'), 'user_id':uid, 'partner_type':'retailer', 'probability': 1.0, 'planned_cost':po.amount_untaxed})
if not po.order_line:
raise osv.except_osv(_('Error !'),_('You can not confirm purchase order without Purchase Order Lines.'))
for line in po.order_line:
if line.state=='draft':
todo.append(line.id)
current_name = self.name_get(cr, uid, ids)[0][1]
self.pool.get('purchase.order.line').action_confirm(cr, uid, todo, context)
for id in ids:
self.write(cr, uid, [id], {'state' : 'confirmed', 'validator' : uid})
return True
@ -312,11 +318,13 @@ class purchase_order(osv.osv):
def action_invoice_create(self, cr, uid, ids, *args):
res = False
journal_obj = self.pool.get('account.journal')
for o in self.browse(cr, uid, ids):
il = []
todo = []
for ol in o.order_line:
todo.append(ol.id)
if ol.product_id:
a = ol.product_id.product_tmpl_id.property_account_expense.id
if not a:
@ -352,7 +360,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}, context)
self.write(cr, uid, [o.id], {'invoice_id': inv_id})
res = inv_id
return res
@ -579,10 +587,22 @@ class purchase_order_line(osv.osv):
'notes': fields.text('Notes', translate=True),
'order_id': fields.many2one('purchase.order', 'Order Reference', select=True, required=True, ondelete='cascade'),
'account_analytic_id':fields.many2one('account.analytic.account', 'Analytic Account',),
'company_id': fields.related('order_id','company_id',type='many2one',relation='res.company',string='Company')
'company_id': fields.related('order_id','company_id',type='many2one',relation='res.company',string='Company'),
'state': fields.selection([('draft', 'Draft'), ('confirmed', 'Confirmed'), ('done', 'Done'), ('cancel', 'Cancelled')], 'State', required=True, readonly=True,
help=' * The \'Draft\' state is set automatically when purchase order in draft state. \
\n* The \'Confirmed\' state is set automatically as confirm when purchase order in confirm state. \
\n* The \'Done\' state is set automatically when purchase order is set as done. \
\n* The \'Cancelled\' state is set automatically when user cancel purchase order.'),
'invoice_lines': fields.many2many('account.invoice.line', 'purchase_order_line_invoice_rel', 'order_line_id', 'invoice_id', 'Invoice Lines', readonly=True),
'invoiced': fields.boolean('Invoiced', readonly=True),
'partner_id': fields.related('order_id','partner_id',string='Partner',readonly=True,type="many2one", relation="res.partner"),
'date_order': fields.related('order_id','date_order',string='Order Date',readonly=True,type="date")
}
_defaults = {
'product_qty': lambda *a: 1.0
'product_qty': lambda *a: 1.0,
'state': lambda *args: 'draft',
'invoiced': lambda *a: 0,
}
_table = 'purchase_order_line'
_name = 'purchase.order.line'
@ -590,7 +610,7 @@ class purchase_order_line(osv.osv):
def copy_data(self, cr, uid, id, default=None,context={}):
if not default:
default = {}
default.update({'state':'draft', 'move_ids':[]})
default.update({'state':'draft', 'move_ids':[],'invoiced':0,'invoice_lines':[]})
return super(purchase_order_line, self).copy_data(cr, uid, id, default, context)
def product_id_change(self, cr, uid, ids, pricelist, product, qty, uom,
@ -666,6 +686,9 @@ class purchase_order_line(osv.osv):
if not uom:
res['value']['price_unit'] = 0.0
return res
def action_confirm(self, cr, uid, ids, context={}):
self.write(cr, uid, ids, {'state': 'confirmed'}, context)
return True
purchase_order_line()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -93,6 +93,8 @@
<field name="product_uom"/>
<field name="price_unit"/>
<field name="price_subtotal"/>
<field name="invoiced"/>
<field name="state"/>
</tree>
<!-- default form view -->
</field>
@ -251,8 +253,15 @@
<field name="account_analytic_id" colspan="4"/>
<separator colspan="4" string="Taxes"/>
<field colspan="4" nolabel="1" name="taxes_id" domain="[('parent_id','=',False),('type_tax_use','!=','sale')]"/>
<separator colspan="4" string="Manual Invoices"/>
<field name="invoiced"/>
<newline/>
<field colspan="4" name="invoice_lines" nolabel="1" widget="many2many"/>
</page>
</notebook>
<group>
<field name="state" />
</group>
</form>
</field>
</record>
@ -271,6 +280,7 @@
<field name="product_uom"/>
<field name="price_unit"/>
<field name="price_subtotal"/>
<field name="invoiced"/>
</tree>
</field>
</record>
@ -299,5 +309,47 @@
<field name="model">purchase.order</field>
</record>
-->
<record id="purchase_line_form_action" model="ir.actions.act_window">
<field name="name">Purchase Order Lines</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">purchase.order.line</field>
<field name="view_mode">tree,form</field>
</record>
<record id="purchase_line_form_action_tree" model="ir.actions.act_window.view">
<field eval="1" name="sequence"/>
<field name="view_mode">tree</field>
<field name="view_id" ref="purchase_order_line_tree"/>
<field name="act_window_id" ref="purchase_line_form_action"/>
</record>
<record id="purchase_line_form_action_form" model="ir.actions.act_window.view">
<field eval="2" name="sequence"/>
<field name="view_mode">form</field>
<field name="view_id" ref="purchase_order_line_form"/>
<field name="act_window_id" ref="purchase_line_form_action"/>
</record>
<menuitem action="purchase_line_form_action" id="menu_purchase_line_form_action" parent="base.menu_purchase_root"/>
<record id="purchase_line_form_action2" model="ir.actions.act_window">
<field name="name">Uninvoiced Purchase Order Lines</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="view_type">form</field>
<field name="view_mode">tree,form</field>
</record>
<record id="purchase_line_form_action_tree2" model="ir.actions.act_window.view">
<field eval="1" name="sequence"/>
<field name="view_mode">tree</field>
<field name="view_id" ref="purchase_order_line_tree"/>
<field name="act_window_id" ref="purchase_line_form_action2"/>
</record>
<record id="purchase_line_form_action_form2" model="ir.actions.act_window.view">
<field eval="2" name="sequence"/>
<field name="view_mode">form</field>
<field name="view_id" ref="purchase_order_line_form"/>
<field name="act_window_id" ref="purchase_line_form_action2"/>
</record>
<menuitem action="purchase_line_form_action2" id="menu_purchase_line_order_draft" parent="menu_purchase_line_form_action"/>
</data>
</openerp>

View File

@ -21,5 +21,6 @@
import purchase_order_group
import purchase_installer
import purchase_line_invoice
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -1,24 +0,0 @@
# -*- 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 purchase_manual
import wizard

View File

@ -1,42 +0,0 @@
# -*- 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/>.
#
##############################################################################
{
'name': 'Purchase Management - Manual Control of Invoice',
'version': '1.1',
'category': 'Generic Modules/Sales & Purchases',
'description': """Module for purchase management, manual control of invoice""",
'author': 'Tiny',
'website': 'http://www.openerp.com',
'depends': ['purchase'],
'init_xml': [],
'update_xml': [
'purchase_manual_view.xml',
'wizard/purchase_line_invoice_view.xml',
],
'demo_xml': [],
'installable': True,
'active': False,
# 'certificate': False,
}
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -1,81 +0,0 @@
# -*- 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/>.
#
##############################################################################
from osv import fields
from osv import osv
import netsvc
class purchase_order_line(osv.osv):
_inherit='purchase.order.line'
_columns = {
'state': fields.selection([('draft', 'Draft'), ('confirmed', 'Confirmed'), ('done', 'Done'), ('cancel', 'Cancelled')], 'State', required=True, readonly=True,
help=' * The \'Draft\' state is set automatically when purchase order in draft state. \
\n* The \'Confirmed\' state is set automatically as confirm when purchase order in confirm state. \
\n* The \'Done\' state is set automatically when purchase order is set as done. \
\n* The \'Cancelled\' state is set automatically when user cancel purchase order.'),
'invoice_lines': fields.many2many('account.invoice.line', 'purchase_order_line_invoice_rel', 'order_line_id', 'invoice_id', 'Invoice Lines', readonly=True),
'invoiced': fields.boolean('Invoiced', readonly=True),
'partner_id': fields.related('order_id','partner_id',string='Partner',readonly=True,type="many2one", relation="res.partner"),
'date_order': fields.related('order_id','date_order',string='Order Date',readonly=True,type="date")
}
_defaults = {
'state': lambda *args: 'draft',
'invoiced': lambda *a: 0,
}
def copy_data(self, cr, uid, id, default=None, context={}):
print 'copy called'
if not default:
default = {}
default.update({
'state':'draft',
'invoiced':0,
'invoice_lines':[],
})
return super(purchase_order_line, self).copy_data(cr, uid, id, default, context)
def action_confirm(self, cr, uid, ids, context={}):
self.write(cr, uid, ids, {'state': 'confirmed'}, context)
return True
purchase_order_line()
class purchase_order(osv.osv):
_inherit='purchase.order'
def action_invoice_create(self, cr, uid, ids, context={}):
print 'Invoice Create'
res = super(purchase_order, self).action_invoice_create(cr, uid, ids, context)
for po in self.browse(cr, uid, ids, context):
todo = []
for line in po.order_line:
todo.append(line.id)
self.pool.get('purchase.order.line').write(cr, uid, todo, {'invoiced':True}, context)
return res
def wkf_confirm_order(self, cr, uid, ids, context={}):
res = super(purchase_order, self).wkf_confirm_order(cr, uid, ids, context)
todo = []
for po in self.browse(cr, uid, ids, context):
for line in po.order_line:
if line.state=='draft':
todo.append(line.id)
self.pool.get('purchase.order.line').action_confirm(cr, uid, todo, context)
return res
purchase_order()

View File

@ -1,105 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
#
# Define PO Line Views
#
<record id="purchase_order_form" model="ir.ui.view">
<field name="name">purchase.order.form</field>
<field name="model">purchase.order</field>
<field name="type">form</field>
<field name="inherit_id" ref="purchase.purchase_order_form"/>
<field name="arch" type="xml">
<xpath expr="/form/notebook/page[@string='Purchase Order']/field[@name='order_line']/tree/field[@name='price_subtotal']" position="after">
<field name="invoiced"/>
<field name="state"/>
</xpath>
</field>
</record>
<record id="purchase_order_line_form" model="ir.ui.view">
<field name="name">purchase.order.line.form</field>
<field name="model">purchase.order.line</field>
<field name="type">form</field>
<field name="inherit_id" ref="purchase.purchase_order_line_form"/>
<field name="priority">17</field>
<field name="arch" type="xml">
<data>
<xpath expr="/form/notebook/page[@string='Invoicing']" position="inside">
<separator colspan="4" string="Manual Invoices"/>
<field name="invoiced"/>
<newline/>
<field colspan="4" name="invoice_lines" nolabel="1" widget="many2many"/>
</xpath>
<xpath expr="/form/notebook" position="after">
<group>
<field name="state" />
</group>
</xpath>
</data>
</field>
</record>
<record id="purchase_order_line_tree" model="ir.ui.view">
<field name="name">purchase.order.line.tree</field>
<field name="model">purchase.order.line</field>
<field name="type">tree</field>
<field name="inherit_id" ref="purchase.purchase_order_line_tree"/>
<field name="arch" type="xml">
<field name="price_subtotal" position="after">
<field name="invoiced"/>
</field>
</field>
</record>
#
# Inherit PO view to get buttons
#
<record id="purchase_line_form_action" model="ir.actions.act_window">
<field name="name">Purchase Order Lines</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">purchase.order.line</field>
<field name="view_mode">tree,form</field>
</record>
<record id="purchase_line_form_action_tree" model="ir.actions.act_window.view">
<field eval="1" name="sequence"/>
<field name="view_mode">tree</field>
<field name="view_id" ref="purchase_order_line_tree"/>
<field name="act_window_id" ref="purchase_line_form_action"/>
</record>
<record id="purchase_line_form_action_form" model="ir.actions.act_window.view">
<field eval="2" name="sequence"/>
<field name="view_mode">form</field>
<field name="view_id" ref="purchase_order_line_form"/>
<field name="act_window_id" ref="purchase_line_form_action"/>
</record>
<menuitem action="purchase_line_form_action" id="menu_purchase_line_form_action" parent="base.menu_purchase_root"/>
<record id="purchase_line_form_action2" model="ir.actions.act_window">
<field name="name">Uninvoiced Purchase Order Lines</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="view_type">form</field>
<field name="view_mode">tree,form</field>
</record>
<record id="purchase_line_form_action_tree2" model="ir.actions.act_window.view">
<field eval="1" name="sequence"/>
<field name="view_mode">tree</field>
<field name="view_id" ref="purchase_order_line_tree"/>
<field name="act_window_id" ref="purchase_line_form_action2"/>
</record>
<record id="purchase_line_form_action_form2" model="ir.actions.act_window.view">
<field eval="2" name="sequence"/>
<field name="view_mode">form</field>
<field name="view_id" ref="purchase_order_line_form"/>
<field name="act_window_id" ref="purchase_line_form_action2"/>
</record>
<menuitem action="purchase_line_form_action2" id="menu_purchase_line_order_draft" parent="menu_purchase_line_form_action"/>
</data>
</openerp>

View File

@ -1,23 +0,0 @@
# -*- 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 purchase_line_invoice