[MERGE] merge MTR branch for sale related module cleaning
bzr revid: mra@mra-laptop-20100708041834-fpxlw2mypjzxcm0h
This commit is contained in:
commit
a1e86e0147
|
@ -23,7 +23,6 @@ import time
|
|||
from osv import fields, osv
|
||||
|
||||
class sale_order_line(osv.osv):
|
||||
_name = 'sale.order.line'
|
||||
_inherit = 'sale.order.line'
|
||||
_columns = {
|
||||
'analytics_id':fields.many2one('account.analytic.plan.instance','Analytic Distribution'),
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0"?>
|
||||
<openerp>
|
||||
<data>
|
||||
<data>
|
||||
|
||||
<record model="ir.ui.view" id="view_order_form_inherit">
|
||||
<field name="name">sale.order.form.inherit</field>
|
||||
|
@ -36,5 +36,5 @@
|
|||
</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</data>
|
||||
</openerp>
|
||||
|
|
|
@ -1,47 +1,48 @@
|
|||
<?xml version="1.0"?>
|
||||
<openerp>
|
||||
<data>
|
||||
<data>
|
||||
|
||||
<record model="ir.ui.view" id="crm_case_form_view_oppor">
|
||||
<field name="name">CRM - Opportunities - Quote Inherit</field>
|
||||
<field name="model">crm.lead</field>
|
||||
<field name="type">form</field>
|
||||
<field name="inherit_id" ref="crm.crm_case_form_view_oppor"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="priority" position="after">
|
||||
<button string="Convert to Sale" icon="gtk-go-forward" name="%(action_crm_make_sale)d" type="action"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
<record model="ir.ui.view" id="crm_case_form_view_oppor">
|
||||
<field name="name">CRM - Opportunities - Quote Inherit</field>
|
||||
<field name="model">crm.lead</field>
|
||||
<field name="type">form</field>
|
||||
<field name="inherit_id" ref="crm.crm_case_form_view_oppor"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="priority" position="after">
|
||||
<button string="Convert to Sale" icon="gtk-go-forward" name="%(action_crm_make_sale)d" type="action"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.ui.view" id="sale_view_inherit123">
|
||||
<field name="name">sale.order.inherit</field>
|
||||
<field name="model">sale.order</field>
|
||||
<field name="type">form</field>
|
||||
<field name="inherit_id" ref="sale.view_order_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="user_id" position="after">
|
||||
<field name="section_id" widget="selection" groups="base.group_extended"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="view_sales_order_filter_inherit" model="ir.ui.view">
|
||||
<field name="name">sale.order.list.select</field>
|
||||
<field name="model">sale.order</field>
|
||||
<field name="type">search</field>
|
||||
<field name="inherit_id" ref="sale.view_sales_order_filter"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="date_order" position="after">
|
||||
<field name="section_id" default="context.get('section_id', False)" widget="selection" string="Sale Team" groups="base.group_extended">
|
||||
<filter icon="terp-personal+"
|
||||
domain="[('section_id.user_id','=',uid)]"
|
||||
groups="base.group_extended"
|
||||
help="My Sales Team"/>
|
||||
</field>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
</data>
|
||||
<record model="ir.ui.view" id="sale_view_inherit123">
|
||||
<field name="name">sale.order.inherit</field>
|
||||
<field name="model">sale.order</field>
|
||||
<field name="type">form</field>
|
||||
<field name="inherit_id" ref="sale.view_order_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="user_id" position="after">
|
||||
<field name="section_id" widget="selection" groups="base.group_extended"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="view_sales_order_filter_inherit" model="ir.ui.view">
|
||||
<field name="name">sale.order.list.select</field>
|
||||
<field name="model">sale.order</field>
|
||||
<field name="type">search</field>
|
||||
<field name="inherit_id" ref="sale.view_sales_order_filter"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="date_order" position="after">
|
||||
<field name="section_id" default="context.get('section_id', False)" widget="selection" string="Sale Team" groups="base.group_extended">
|
||||
<filter icon="terp-personal+"
|
||||
domain="[('section_id.user_id','=',uid)]"
|
||||
groups="base.group_extended"
|
||||
help="My Sales Team"/>
|
||||
</field>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ class sale_journal_report(osv.osv):
|
|||
('done', 'Done'),
|
||||
('cancel', 'Cancel')
|
||||
], 'Order State', readonly=True),
|
||||
'journal_id':fields.many2one('sale_journal.sale.journal', 'Journal', readonly=True),
|
||||
'journal_id': fields.many2one('sale_journal.sale.journal', 'Journal', readonly=True),
|
||||
'quantity': fields.float('Quantities', readonly=True),
|
||||
'price_total': fields.float('Total Price', readonly=True),
|
||||
'price_average': fields.float('Average Price', readonly=True),
|
||||
|
@ -86,7 +86,7 @@ class sale_journal_picking_report(osv.osv):
|
|||
_auto = False
|
||||
_columns = {
|
||||
'name': fields.char('Year', size=64, required=False, readonly=True),
|
||||
'month':fields.selection([('01', 'January'), ('02', 'February'), ('03', 'March'), ('04', 'April'), ('05', 'May'), ('06', 'June'),
|
||||
'month': fields.selection([('01', 'January'), ('02', 'February'), ('03', 'March'), ('04', 'April'), ('05', 'May'), ('06', 'June'),
|
||||
('07', 'July'), ('08', 'August'), ('09', 'September'), ('10', 'October'), ('11', 'November'), ('12', 'December')], 'Month', readonly=True),
|
||||
|
||||
'invoice_state':fields.selection([
|
||||
|
@ -103,7 +103,7 @@ class sale_journal_picking_report(osv.osv):
|
|||
('cancel', 'cancel'),
|
||||
], 'State', readonly=True),
|
||||
'invoice_type_id': fields.many2one('sale_journal.invoice.type', 'Invoicing method', readonly=True),
|
||||
'journal_id':fields.many2one('sale_journal.picking.journal', 'Journal', readonly=True),
|
||||
'journal_id': fields.many2one('sale_journal.picking.journal', 'Journal', readonly=True),
|
||||
'quantity': fields.float('Quantities', readonly=True),
|
||||
'price_total': fields.float('Total Price', readonly=True),
|
||||
'price_average': fields.float('Average Price', readonly=True),
|
||||
|
|
|
@ -148,8 +148,8 @@ class picking_journal(osv.osv):
|
|||
'note': fields.text('Note'),
|
||||
}
|
||||
_defaults = {
|
||||
'date': lambda *a: time.strftime('%Y-%m-%d'),
|
||||
'date_created': lambda *a: time.strftime('%Y-%m-%d'),
|
||||
'date': time.strftime('%Y-%m-%d'),
|
||||
'date_created': time.strftime('%Y-%m-%d'),
|
||||
'user_id': lambda self,cr,uid,context: uid,
|
||||
'state': lambda self,cr,uid,context: 'draft',
|
||||
}
|
||||
|
@ -161,12 +161,15 @@ class picking_journal(osv.osv):
|
|||
wf_service = netsvc.LocalService("workflow")
|
||||
wf_service.trg_validate(uid, 'stock.picking', pickid, 'button_cancel', cr)
|
||||
return True
|
||||
|
||||
def button_open(self, cr, uid, ids, context={}):
|
||||
self.write(cr, uid, ids, {'state':'open'})
|
||||
return True
|
||||
|
||||
def button_draft(self, cr, uid, ids, context={}):
|
||||
self.write(cr, uid, ids, {'state':'draft'})
|
||||
return True
|
||||
|
||||
def button_close(self, cr, uid, ids, context={}):
|
||||
self.write(cr, uid, ids, {'state':'done', 'date_validation':time.strftime('%Y-%m-%d')})
|
||||
return True
|
||||
|
@ -197,13 +200,13 @@ class res_partner(osv.osv):
|
|||
_columns = {
|
||||
'property_invoice_type': fields.property(
|
||||
'sale_journal.invoice.type',
|
||||
type='many2one',
|
||||
relation='sale_journal.invoice.type',
|
||||
string="Invoicing Method",
|
||||
method=True,
|
||||
view_load=True,
|
||||
group_name="Accounting Properties",
|
||||
help="The type of journal used for sales and picking."),
|
||||
type = 'many2one',
|
||||
relation = 'sale_journal.invoice.type',
|
||||
string = "Invoicing Method",
|
||||
method = True,
|
||||
view_load = True,
|
||||
group_name = "Accounting Properties",
|
||||
help = "The type of journal used for sales and picking."),
|
||||
}
|
||||
res_partner()
|
||||
|
||||
|
|
|
@ -148,10 +148,12 @@
|
|||
<field name="model">sale.order</field>
|
||||
<field name="inherit_id" ref="sale.view_order_form" />
|
||||
<field name="arch" type="xml">
|
||||
<field name="user_id" position="after">
|
||||
<separator string="Journal" colspan="4"/>
|
||||
<field name="journal_id" select="1" widget="selection"/>
|
||||
<field name="invoice_type_id" select="1" widget="selection"/>
|
||||
<field name="origin" position="after">
|
||||
<group colspan="2" col="2">
|
||||
<separator string="Journal" colspan="4"/>
|
||||
<field name="journal_id" select="1" widget="selection"/>
|
||||
<field name="invoice_type_id" select="1" widget="selection"/>
|
||||
</group>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
@ -403,10 +405,10 @@
|
|||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Picking Journal">
|
||||
<field name="name" select="1"/>
|
||||
<field name="code" select="1"/>
|
||||
<field name="user_id" select="1"/>
|
||||
<field name="date" select="1"/>
|
||||
<field name="name"/>
|
||||
<field name="code"/>
|
||||
<field name="user_id"/>
|
||||
<field name="date"/>
|
||||
<field name="state"/>
|
||||
</tree>
|
||||
</field>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
##############################################################################
|
||||
#
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
|
||||
#
|
||||
|
@ -14,12 +14,12 @@
|
|||
# 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/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
import invoice_margin
|
||||
import report
|
||||
import sale_margin
|
||||
import report
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
|
|
|
@ -21,8 +21,12 @@
|
|||
{
|
||||
"name":"Margins in Sale Orders",
|
||||
"version":"1.0",
|
||||
"author":"Tiny",
|
||||
"category" : "Generic Modules/Sales & Purchases",
|
||||
"description": """
|
||||
This module adds the 'Margin' on sales order,
|
||||
which gives the profitability by calculating the difference between the Unit Price and Cost Price
|
||||
""",
|
||||
"author":"Tiny",
|
||||
"depends":["sale"],
|
||||
"demo_xml":[],
|
||||
"update_xml":["security/ir.model.access.csv","sale_margin_view.xml","report/report_margin_view.xml"],
|
||||
|
|
|
@ -1,44 +0,0 @@
|
|||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2009 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,osv
|
||||
import pooler
|
||||
from tools import config
|
||||
|
||||
class account_invoice_line(osv.osv):
|
||||
_name = "account.invoice.line"
|
||||
_inherit = "account.invoice.line"
|
||||
_columns = {
|
||||
'cost_price': fields.float('Cost Price', digits=(16, 2)),
|
||||
}
|
||||
def write(self, cr, uid, ids, vals, context={}):
|
||||
if vals.get('product_id', False):
|
||||
res = self.pool.get('product.product').read(cr, uid, [vals['product_id']], ['standard_price'])
|
||||
vals['cost_price'] = res[0]['standard_price']
|
||||
return super(account_invoice_line, self).write(cr, uid, ids, vals, context)
|
||||
|
||||
def create(self, cr, uid, vals, context={}):
|
||||
if vals.get('product_id',False):
|
||||
res = self.pool.get('product.product').read(cr, uid, [vals['product_id']], ['standard_price'])
|
||||
vals['cost_price'] = res[0]['standard_price']
|
||||
return super(account_invoice_line, self).create(cr, uid, vals, context)
|
||||
account_invoice_line()
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
|
@ -23,7 +23,6 @@ import pooler
|
|||
from tools import config
|
||||
|
||||
class sale_order_line(osv.osv):
|
||||
_name = "sale.order.line"
|
||||
_inherit = "sale.order.line"
|
||||
|
||||
def product_id_change(self, cr, uid, ids, pricelist, product, qty=0,
|
||||
|
@ -67,7 +66,7 @@ class sale_order(osv.osv):
|
|||
return result
|
||||
|
||||
_columns = {
|
||||
'margin': fields.function(_product_margin, method=True, string='Margin', store=True),
|
||||
'margin': fields.function(_product_margin, method=True, string='Margin', store=True, help="It gives profitability by calculating the difference between the Unit Price and Cost Price"),
|
||||
}
|
||||
|
||||
sale_order()
|
||||
|
@ -76,7 +75,7 @@ class stock_picking(osv.osv):
|
|||
_inherit = 'stock.picking'
|
||||
|
||||
_columns = {
|
||||
'invoice_ids': fields.many2many('account.invoice', 'picking_invoice_rel', 'picking_id', 'invoice_id', 'Invoices', domain=[('type','=','in_invoice')]),
|
||||
'invoice_ids': fields.many2many('account.invoice', 'picking_invoice_rel', 'picking_id', 'invoice_id', 'Invoices', domain=[('type','=','out_invoice')]),
|
||||
}
|
||||
|
||||
def create_invoice(self, cr, uid, ids, *args):
|
||||
|
@ -91,4 +90,23 @@ class stock_picking(osv.osv):
|
|||
return True
|
||||
|
||||
stock_picking()
|
||||
|
||||
class account_invoice_line(osv.osv):
|
||||
_inherit = "account.invoice.line"
|
||||
_columns = {
|
||||
'cost_price': fields.float('Cost Price', digits=(16, 2)),
|
||||
}
|
||||
def write(self, cr, uid, ids, vals, context={}):
|
||||
if vals.get('product_id', False):
|
||||
res = self.pool.get('product.product').read(cr, uid, [vals['product_id']], ['standard_price'])
|
||||
vals['cost_price'] = res[0]['standard_price']
|
||||
return super(account_invoice_line, self).write(cr, uid, ids, vals, context)
|
||||
|
||||
def create(self, cr, uid, vals, context={}):
|
||||
if vals.get('product_id',False):
|
||||
res = self.pool.get('product.product').read(cr, uid, [vals['product_id']], ['standard_price'])
|
||||
vals['cost_price'] = res[0]['standard_price']
|
||||
return super(account_invoice_line, self).create(cr, uid, vals, context)
|
||||
|
||||
account_invoice_line()
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
|
@ -67,15 +67,15 @@
|
|||
<field name="name">picking.margin.view.form</field>
|
||||
<field name="type">form</field>
|
||||
<field name="model">stock.picking</field>
|
||||
<field name="inherit_id" ref="stock.view_picking_in_form" />
|
||||
<field name="inherit_id" ref="stock.view_picking_out_form" />
|
||||
<field name="arch" type="xml">
|
||||
<notebook colspan="4">
|
||||
<page string="Supplier Invoices">
|
||||
<page string="Customer Invoices">
|
||||
<separator string="Invoices" colspan="4"/>
|
||||
<field colspan="4" name="invoice_ids" nolabel="1"/>
|
||||
<group col="10" colspan="4">
|
||||
<label colspan="6"/>
|
||||
<button name="create_invoice" icon='gtk-execute' string="Create Invoice" type="object"/>
|
||||
<label colspan="6"/>
|
||||
<button name="create_invoice" icon='gtk-execute' string="Create Invoice" type="object"/>
|
||||
</group>
|
||||
</page>
|
||||
</notebook>
|
||||
|
|
|
@ -25,29 +25,31 @@ from osv import osv, fields
|
|||
class mrp_production(osv.osv):
|
||||
_inherit = 'mrp.production'
|
||||
|
||||
def _ref_calc(self, cr, uid, ids, field_names=None, arg=False, context={}):
|
||||
def _ref_calc(self, cr, uid, ids, field_names=None, arg=False, context=None):
|
||||
""" Finds reference of sale order for production order.
|
||||
@param field_names: Names of fields.
|
||||
@param arg: User defined arguments
|
||||
@return: Dictionary of values.
|
||||
"""
|
||||
res = {}
|
||||
if context is None:
|
||||
context = {}
|
||||
if not field_names:
|
||||
field_names = []
|
||||
res = {}
|
||||
for id in ids:
|
||||
res[id] = {}.fromkeys(field_names, False)
|
||||
for f in field_names:
|
||||
field_name = False
|
||||
if f == 'sale_name':
|
||||
field_name = 'name'
|
||||
if f=='sale_ref':
|
||||
if f == 'sale_ref':
|
||||
field_name = 'client_order_ref'
|
||||
for key, value in self._get_sale_ref(cr, uid, ids, field_name).items():
|
||||
res[key][f] = value
|
||||
return res
|
||||
|
||||
def _get_sale_ref(self, cr, uid, ids, field_name=False):
|
||||
move_obj=self.pool.get('stock.move')
|
||||
move_obj = self.pool.get('stock.move')
|
||||
|
||||
def get_parent_move(move_id):
|
||||
move = move_obj.browse(cr, uid, move_id)
|
||||
|
@ -55,8 +57,8 @@ class mrp_production(osv.osv):
|
|||
return get_parent_move(move.move_dest_id.id)
|
||||
return move_id
|
||||
|
||||
res = {}
|
||||
productions = self.read(cr, uid, ids, ['id','move_prod_id'])
|
||||
res={}
|
||||
for production in productions:
|
||||
res[production['id']] = False
|
||||
if production.get('move_prod_id',False):
|
||||
|
@ -65,7 +67,7 @@ class mrp_production(osv.osv):
|
|||
move = move_obj.browse(cr,uid,parent_move_line)
|
||||
if field_name == 'name':
|
||||
res[production['id']] = move.sale_line_id and move.sale_line_id.order_id.name or False
|
||||
if field_name=='client_order_ref':
|
||||
if field_name == 'client_order_ref':
|
||||
res[production['id']] = move.sale_line_id and move.sale_line_id.order_id.client_order_ref or False
|
||||
return res
|
||||
|
||||
|
|
Loading…
Reference in New Issue