res[id] = round(res.get(id, 0.0),2) + round(res2.get(id, 0.0),2)
return res
- def _last_worked_date_calc (self, cr, uid, ids, name, arg, context = None):
+ def _last_worked_date_calc (self, cr, uid, ids, name, arg, context=None):
res = {}
parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)]))
if parent_ids:
'month_ids': fields.function(_month, method=True, type='many2many', relation='account_analytic_analysis.summary.month', string='Month'),
'user_ids': fields.function(_user, method=True, type="many2many", relation='account_analytic_analysis.summary.user', string='User'),
}
+
account_analytic_account()
class account_analytic_account_summary_user(osv.osv):
res.extend(cr.dictfetchall())
else:
res = map(lambda x: {'id': x}, ids)
-
+ res_trans_obj = self.pool.get('ir.translation')
for f in fields_pre:
if self._columns[f].translate:
ids = map(lambda x: x['id'], res)
- res_trans = self.pool.get('ir.translation')._get_ids(cr, user, self._name+','+f, 'model', context.get('lang', False) or 'en_US', ids)
+ res_trans = res_trans_obj._get_ids(cr, user, self._name+','+f, 'model', context.get('lang', False) or 'en_US', ids)
for r in res:
r[f] = res_trans.get(r['id'], False) or r[f]
res.extend(cr.dictfetchall())
else:
res = map(lambda x: {'id': x}, ids)
-
+
+ res_trans_obj = self.pool.get('ir.translation')
for f in fields_pre:
if self._columns[f].translate:
ids = map(lambda x: x['id'], res)
- res_trans = self.pool.get('ir.translation')._get_ids(cr, user, self._name+','+f, 'model', context.get('lang', False) or 'en_US', ids)
+ res_trans = res_trans_obj._get_ids(cr, user, self._name+','+f, 'model', context.get('lang', False) or 'en_US', ids)
for r in res:
r[f] = res_trans.get(r['id'], False) or r[f]
""",
'author' : 'Tiny',
'website' : 'http://www.openerp.com',
- 'depends' : ['account', 'sale'],
+ 'depends' : ['sale'],
'init_xml' : [],
'update_xml': ['security/ir.model.access.csv', 'account_analytic_default_view.xml'],
'demo_xml' : [],
'date_start': fields.date('Start Date'),
'date_stop': fields.date('End Date'),
}
+
def account_get(self, cr, uid, product_id=None, partner_id=None, user_id=None, date=None, context=None):
domain = []
if product_id:
res = rec
best_index = index
return res
+
account_analytic_default()
class account_invoice_line(osv.osv):
else:
res_prod['value'].update({'account_analytic_id':False})
return res_prod
+
account_invoice_line()
create_ids = super(sale_order_line,self).invoice_line_create(cr, uid, ids, context)
if not ids:
return create_ids
- sale_line_obj = self.browse(cr, uid, ids[0], context)
- pool_inv_line = self.pool.get('account.invoice.line')
-
- for line in pool_inv_line.browse(cr, uid, create_ids, context):
- rec = self.pool.get('account.analytic.default').account_get(cr, uid, line.product_id.id, sale_line_obj.order_id.partner_id.id, uid, time.strftime('%Y-%m-%d'), context)
+ sale_line = self.browse(cr, uid, ids[0], context)
+ inv_line_obj = self.pool.get('account.invoice.line')
+ anal_def_obj = self.pool.get('account.analytic.default')
+ for line in inv_line_obj.browse(cr, uid, create_ids, context):
+ rec = anal_def_obj.account_get(cr, uid, line.product_id.id, sale_line.order_id.partner_id.id, uid, time.strftime('%Y-%m-%d'), context)
if rec:
- pool_inv_line.write(cr, uid, [line.id], {'account_analytic_id':rec.analytic_id.id}, context=context)
+ inv_line_obj.write(cr, uid, [line.id], {'account_analytic_id':rec.analytic_id.id}, context=context)
return create_ids
sale_order_line()
'name': fields.char('Analytic Plan', size=64, required=True, select=True,),
'plan_ids': fields.one2many('account.analytic.plan.line','plan_id','Analytic Plans'),
}
+
account_analytic_plan()
class account_analytic_plan_line(osv.osv):
'min_required': 100.0,
'max_required': 100.0,
}
+
account_analytic_plan_line()
class account_analytic_plan_instance(osv.osv):
pids = self.pool.get('account.analytic.plan.instance').search(cr, uid, [('name','=',vals['name']),('code','=',vals['code']),('plan_id','<>',False)])
if pids:
raise osv.except_osv(_('Error'), _('A model having this name and code already exists !'))
-
- res = self.pool.get('account.analytic.plan.line').search(cr, uid, [('plan_id','=',journal.plan_id.id)])
+
+ acct_anal_acct = self.pool.get('account.analytic.account')
+ acct_anal_plan_line_obj = self.pool.get('account.analytic.plan.line')
+ res = acct_anal_plan_line_obj.search(cr, uid, [('plan_id','=',journal.plan_id.id)])
for i in res:
total_per_plan = 0
- item = self.pool.get('account.analytic.plan.line').browse(cr, uid, i)
+ item = acct_anal_plan_line_obj.browse(cr, uid, i)
temp_list=['account1_ids','account2_ids','account3_ids','account4_ids','account5_ids','account6_ids']
for l in temp_list:
if vals.has_key(l):
for tempo in vals[l]:
- if self.pool.get('account.analytic.account').search(cr, uid, [('parent_id','child_of',[item.root_analytic_id.id]),('id','=',tempo[2]['analytic_account_id'])]):
+ if acct_anal_acct.search(cr, uid, [('parent_id','child_of',[item.root_analytic_id.id]),('id','=',tempo[2]['analytic_account_id'])]):
total_per_plan += tempo[2]['rate']
if total_per_plan < item.min_required or total_per_plan > item.max_required:
raise osv.except_osv(_('Value Error') ,_('The Total Should be Between %s and %s') % (str(item.min_required), str(item.max_required)))
_columns = {
'plan_id':fields.many2one('account.analytic.plan', 'Analytic Plans'),
}
+
account_journal()
class account_invoice_line(osv.osv):
if rec and rec.analytics_id:
res_prod['value'].update({'analytics_id':rec.analytics_id.id})
return res_prod
+
account_invoice_line()
class account_move_line(osv.osv):
sign = -1
iml = self.pool.get('account.invoice.line').move_line_get(cr, uid, inv.id)
+ acct_ins_obj = self.pool.get('account.analytic.plan.instance')
for il in iml:
if il['analytics_id']:
ref = inv.reference
else:
ref = self._convert_ref(cr, uid, inv.number)
- obj_move_line=self.pool.get('account.analytic.plan.instance').browse(cr, uid, il['analytics_id'])
- amount_calc=cur_obj.compute(cr, uid, inv.currency_id.id, company_currency, il['price'], context={'date': inv.date_invoice}) * sign
- qty=il['quantity']
+ obj_move_line = acct_ins_obj.browse(cr, uid, il['analytics_id'])
+ amount_calc = cur_obj.compute(cr, uid, inv.currency_id.id, company_currency, il['price'], context={'date': inv.date_invoice}) * sign
+ qty = il['quantity']
il['analytic_lines']=[]
for line2 in obj_move_line.account_ids:
- amt=amount_calc * (line2.rate/100)
- qtty=qty* (line2.rate/100)
- al_vals={
+ amt = amount_calc * (line2.rate/100)
+ qtty = qty* (line2.rate/100)
+ al_vals = {
'name': il['name'],
'date': inv['date_invoice'],
'unit_amount':qtty,
_columns = {
'analytics_id': fields.many2one('account.analytic.plan.instance', 'Analytic Distribution'),
}
+
analytic_default()
class sale_order_line(osv.osv):
def invoice_line_create(self, cr, uid, ids, context=None):
create_ids = super(sale_order_line,self).invoice_line_create(cr, uid, ids, context)
if ids:
- sale_line_obj = self.browse(cr, uid, ids[0], context)
- pool_inv_line = self.pool.get('account.invoice.line')
-
- for line in pool_inv_line.browse(cr, uid, create_ids, context):
- rec = self.pool.get('account.analytic.default').account_get(cr, uid, line.product_id.id, sale_line_obj.order_id.partner_id.id, uid, time.strftime('%Y-%m-%d'), context)
+ sale_line = self.browse(cr, uid, ids[0], context)
+ inv_line_obj = self.pool.get('account.invoice.line')
+ acct_anal_def_obj = self.pool.get('account.analytic.default')
+
+ for line in inv_line_obj.browse(cr, uid, create_ids, context):
+ rec = acct_anal_def_obj.account_get(cr, uid, line.product_id.id, sale_line.order_id.partner_id.id, uid, time.strftime('%Y-%m-%d'), context)
if rec:
- pool_inv_line.write(cr, uid, [line.id], {'analytics_id':rec.analytics_id.id}, context=context)
+ inv_line_obj.write(cr, uid, [line.id], {'analytics_id':rec.analytics_id.id}, context=context)
return create_ids
sale_order_line()
import stock
import purchase
import invoice
+
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
\ No newline at end of file
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
+
{
- "name" : "Stock Accounting for Anglo Saxon countries",
- "version" : "1.2",
- "author" : "Tiny, Veritos",
- "website" : "http://tinyerp.com - http://veritos.nl",
+ "name" : "Stock Accounting for Anglo Saxon countries",
+ "version" : "1.2",
+ "author" : "Tiny, Veritos",
+ "website" : "http://tinyerp.com - http://veritos.nl",
"description" : """This module will support the Anglo-Saxons accounting methodology by
changing the accounting logic with stock transactions. The difference between the Anglo-Saxon accounting countries
and the Rhine or also called Continental accounting countries is the moment of taking the Cost of Goods Sold versus Cost of Sales.
This module will add this functionality by using a interim account, to store the value of shipped goods and will contra book this interim account
when the invoice is created to transfer this amount to the debtor or creditor account.
Secondly, price differences between actual purchase price and fixed product standard price are booked on a seperate account""",
- "depends" : ["product", "account", "sale", "purchase", "stock"],
- "category" : "Generic Modules/Inventory Control",
- "init_xml" : [],
- "demo_xml" : [],
+ "depends" : ["product", "purchase"],
+ "category" : "Generic Modules/Inventory Control",
+ "init_xml" : [],
+ "demo_xml" : [],
"update_xml" : ["product_view.xml",],
- "active": False,
+ "active" : False,
"installable": True
}
+
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
\ No newline at end of file
<field name="name">product.normal.form.inherit.stock</field>
<field name="model">product.product</field>
<field name="type">form</field>
- <field name="inherit_id" ref="product.product_normal_form_view"/>
+ <field name="inherit_id" ref="account.product_normal_form_view"/>
<field name="arch" type="xml">
<xpath expr="/form/notebook/page/field[@name='property_account_expense']" position="after">
<field name="property_account_creditor_price_difference" domain="[('type','<>','view'),('type','<>','consolidation')]" attrs="{'readonly':[('purchase_ok','=',0)]}" />
<newline/>
-<!-- <field name="property_account_sending_goods" domain="[('type','<>','view'),('type','<>','consolidation')]" attrs="{'readonly':[('sale_ok','=',0)]}" />-->
-<!-- <field name="property_account_received_goods" domain="[('type','<>','view'),('type','<>','consolidation')]" attrs="{'readonly':[('purchase_ok','=',0)]}" />-->
</xpath>
</field>
</record>
<field name="name">product.template.product.form.inherit</field>
<field name="model">product.template</field>
<field name="type">form</field>
- <field name="inherit_id" ref="product.product_template_form_view"/>
+ <field name="inherit_id" ref="account.product_template_form_view"/>
<field name="arch" type="xml">
<xpath expr="/form/notebook/page/field[@name='property_account_expense']" position="after">
<field name="property_account_creditor_price_difference" domain="[('type','<>','view'),('type','<>','consolidation')]" attrs="{'readonly':[('purchase_ok','=',0)]}" />
<newline/>
-<!-- <field name="property_account_sending_goods" domain="[('type','<>','view'),('type','<>','consolidation')]" attrs="{'readonly':[('sale_ok','=',0)]}" />-->
-<!-- <field name="property_account_received_goods" domain="[('type','<>','view'),('type','<>','consolidation')]" attrs="{'readonly':[('purchase_ok','=',0)]}" />-->
</xpath>
</field>
</record>
<group col="2" colspan="2">
<separator string=" Accounting Property" colspan="2"/>
<field name="property_account_creditor_price_difference_categ" domain="[('type','<>','view'),('type','<>','consolidation')]" attrs="{'readonly':[('purchase_ok','=',0)]}" />
-<!-- <field name="property_account_sending_goods_categ" domain="[('type','<>','view'),('type','<>','consolidation')]" attrs="{'readonly':[('sale_ok','=',0)]}" />-->
-<!-- <field name="property_account_received_goods_categ" domain="[('type','<>','view'),('type','<>','consolidation')]" attrs="{'readonly':[('purchase_ok','=',0)]}" />-->
</group>
</form>
</field>
import crossovered_budget
import report
import wizard
+
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
##############################################################################
from osv import osv,fields
-import tools
-import netsvc
-from mx import DateTime
-import time
import datetime
from tools.translate import _
-
def strToDate(dt):
dt_date=datetime.date(int(dt[0:4]),int(dt[5:7]),int(dt[8:10]))
return dt_date
'creating_user_id': lambda self,cr,uid,context: uid,
}
-# def action_set_to_draft(self, cr, uid, ids, *args):
-# self.write(cr, uid, ids, {'state': 'draft'})
-# wf_service = netsvc.LocalService('workflow')
-# for id in ids:
-# wf_service.trg_create(uid, self._name, id, cr)
-# return True
-
def budget_confirm(self, cr, uid, ids, *args):
self.write(cr, uid, ids, {
'state':'confirm'
#
##############################################################################
-
{
"name" : "Account Cancel",
"version" : "1.1",
- "depends" : ["account"],
"author" : "Tiny",
"category": 'Generic Modules/Accounting',
"description": """
- Module Add Allow cancelling entries field on form view of account journal if it set to true it allows user to cancel entries & invoices.
+ Module adds 'Allow cancelling entries' field on form view of account journal. If set to true it allows user to cancel entries & invoices.
""",
'website': 'http://www.openerp.com',
+ "depends" : ["account"],
'init_xml': [],
'update_xml': ['account_cancel_view.xml' ],
'demo_xml': [],
'active': False,
}
+
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
import account_coda
import wizard
+
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
##############################################################################
{
- "name":"Account CODA - import bank statements from coda file",
- "version":"1.0",
- "author":"Tiny",
- "category":"Account CODA",
- "description":"""
+ "name" : "Account CODA - import bank statements from coda file",
+ "version" : "1.0",
+ "author" : "Tiny",
+ "category" : "Account CODA",
+ "description": """
Module provides functionality to import
bank statements from coda files.
""",
- "depends":["base", "account"],
- "demo_xml":["account_coda_demo.xml"],
- "init_xml":[],
- "update_xml" : ["security/ir.model.access.csv",
+ "depends" : ["account"],
+ "demo_xml" : [],
+ "init_xml" : [],
+ "update_xml": ["security/ir.model.access.csv",
"wizard/account_coda_import.xml",
"account_coda_view.xml"],
- "active":False,
- "installable":True,
+ "active" : False,
+ "installable" : True,
}
+
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
_name = "account.coda"
_description = "coda for an Account"
_columns = {
- 'name': fields.binary('Coda file', readonly=True ,help="Store the detail of bank statements"),
- 'statement_ids': fields.one2many('account.bank.statement','coda_id','Generated Bank Statements', readonly=True),
+ 'name': fields.binary('Coda file', readonly=True, help="Store the detail of bank statements"),
+ 'statement_ids': fields.one2many('account.bank.statement', 'coda_id', 'Generated Bank Statements', readonly=True),
'note': fields.text('Import log', readonly=True),
- 'journal_id': fields.many2one('account.journal','Journal', readonly=True, select=True,help="Bank Journal"),
+ 'journal_id': fields.many2one('account.journal', 'Journal', readonly=True, select=True, help="Bank Journal"),
'date': fields.date('Date', readonly=True, select=True, help="Import Date"),
- 'user_id': fields.many2one('res.users','User', readonly=True, select=True),
+ 'user_id': fields.many2one('res.users', 'User', readonly=True, select=True),
}
_defaults = {
'date': time.strftime('%Y-%m-%d'),
'user_id': lambda self,cr,uid,context: uid,
}
+
account_coda()
class account_bank_statement(osv.osv):
_inherit = "account.bank.statement"
_columns = {
- 'coda_id':fields.many2one('account.coda','Coda'),
+ 'coda_id':fields.many2one('account.coda', 'Coda'),
}
+
account_bank_statement()
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
-
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
\ No newline at end of file
+++ /dev/null
-0000006060712505 00000CPH CODA TINY 0047747270100477472701 00000 1\r
-1 049126201326907 EUR0BE 0000000015632900050607TINY COMPTE COURANT ORDINAIRE 049\r
-2100010000 0000000001150000060607001500000INVOICE OF 2006-12-19 0606070020100\r
-2200010000 EUR000000001150000 100\r
-2300010000301915554082 PROLIBRE SARL CAROUGE GE 000\r
-2100020000 0000000000500000060607001500000CONTRACT PARTNER ERREUR ECART YEA 0606070030100\r
-2200020000RTY CONTRACT PARTNER EUR000000000500000 100\r
-2300020000050000000017 SEDNACOM 43 ALLEE DES FOUGERES 9522 0 HERBLAY 000\r
-8049126201326907 0000000017282900060607 \r
-9 000008000000000000000000000001650000 2\r
--- /dev/null
+0000006060712505 00000CPH CODA TINY 0047747270100477472701 00000 1\r
+1 049126201326907 EUR0BE 0000000015632900050607TINY COMPTE COURANT ORDINAIRE 049\r
+2100010000 0000000001150000060607001500000INVOICE OF 2006-12-19 0606070020100\r
+2200010000 EUR000000001150000 100\r
+2300010000301915554082 PROLIBRE SARL CAROUGE GE 000\r
+2100020000 0000000000500000060607001500000CONTRACT PARTNER ERREUR ECART YEA 0606070030100\r
+2200020000RTY CONTRACT PARTNER EUR000000000500000 100\r
+2300020000050000000017 SEDNACOM 43 ALLEE DES FOUGERES 9522 0 HERBLAY 000\r
+8049126201326907 0000000017282900060607 \r
+9 000008000000000000000000000001650000 2\r
##############################################################################
import time
-from mx import DateTime
import base64
from osv import fields
'coda': fields.binary('Coda File', required=True),
'note':fields.text('Log'),
}
- def coda_parsing(self, cr, uid, ids, context):
+
+ def coda_parsing(self, cr, uid, ids, context=None):
journal_obj=self.pool.get('account.journal')
account_period_obj = self.pool.get('account.period')
statement_reconcile_obj = self.pool.get('account.bank.statement.reconcile')
account_coda_obj = self.pool.get('account.coda')
mod_obj = self.pool.get('ir.model.data')
-
+
+ if not context:
+ context = {}
+
data = self.read(cr, uid, ids)[0]
-
codafile = data['coda']
journal_code = journal_obj.browse(cr, uid, data['journal_id'], context).code
context.update({ 'statment_ids':bkst_list})
model_data_ids = mod_obj.search(cr, uid, [('model', '=', 'ir.ui.view'), ('name', '=', 'account_coda_note_view')], context=context)
resource_id = mod_obj.read(cr, uid, model_data_ids, fields=['res_id'], context=context)[0]['res_id']
+
return {
'name': _('Result'),
'res_id': ids[0],
'context': context,
'type': 'ir.actions.act_window',
}
- def action_open_window(self, cr, uid, data, context):
+
+ def action_open_window(self, cr, uid, data, context=None):
+ if not context:
+ cotext = {}
return {
'domain':"[('id','in',%s)]"%(context.get('statment_ids', False)),
'name': 'Statement',
'view_id': False,
'type': 'ir.actions.act_window',
}
+
account_coda_import()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
\ No newline at end of file
'active': False,
'certificate': '0070514190381',
}
+
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
import time
from osv import fields, osv
-import decimal_precision as dp
class account_invoice(osv.osv):
_inherit = "account.invoice"
return super(account_invoice_line, self)._price_unit_default(cr, uid, context)
return 0
- def _get_invoice(self, cr, uid, ids, context):
+ def _get_invoice(self, cr, uid, ids, context=None):
result = {}
for inv in self.pool.get('account.invoice').browse(cr, uid, ids, context=context):
for line in inv.invoice_line:
_columns = {
'price_subtotal': fields.function(_amount_line2, method=True, string='Subtotal w/o tax', multi='amount',
- store={'account.invoice':(_get_invoice,['price_type'],10), 'account.invoice.line': (lambda self, cr, uid, ids, c={}: ids, None,10)}),
+ store={'account.invoice':(_get_invoice,['price_type'], 10), 'account.invoice.line': (lambda self, cr, uid, ids, c={}: ids, None,10)}),
'price_subtotal_incl': fields.function(_amount_line2, method=True, string='Subtotal', multi='amount',
- store={'account.invoice':(_get_invoice,['price_type'],10), 'account.invoice.line': (lambda self, cr, uid, ids, c={}: ids, None,10)}),
+ store={'account.invoice':(_get_invoice,['price_type'], 10), 'account.invoice.line': (lambda self, cr, uid, ids, c={}: ids, None,10)}),
}
_defaults = {
""",
"category" : "Generic Modules/Accounting",
"website" : "http://tinyerp.com",
- "depends" : [
- "base",
- "account"
- ],
- "init_xml" : [
- ],
+ "depends" : ["account"],
+ "init_xml" : [],
- "demo_xml" : [
- ],
+ "demo_xml" : [],
"update_xml" : [
"security/ir.model.access.csv",
import report
import wizard
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
-
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
\ No newline at end of file
#
##############################################################################
-
{
"name" : "Inventory Management",
"version" : "1.1",
"wizard/stock_traceability_view.xml",
"stock_workflow.xml",
"stock_incoterms.xml",
- "stock_wizard.xml",
"stock_view.xml",
"stock_report.xml",
"stock_sequence.xml",
<menuitem icon="terp-graph" id="menu_dashboard_stock" name="Dashboard" sequence="0" parent="stock.next_id_61"/>
<menuitem action="open_board_warehouse" icon="terp-graph" id="menu_board_warehouse" parent="menu_dashboard_stock" sequence="1"/>
+
</data>
</openerp>
\ No newline at end of file
# -*- coding: utf-8 -*-
##############################################################################
-#
+#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# 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 ir
class res_partner(osv.osv):
- _name = 'res.partner'
_inherit = 'res.partner'
_columns = {
'property_stock_customer': fields.property(
'stock.location',
- type='many2one',
- relation='stock.location',
- string="Customer Location",
+ type='many2one',
+ relation='stock.location',
+ string="Customer Location",
method=True,
view_load=True,
help="This stock location will be used, instead of the default one, as the destination location for goods you send to this partner"),
+
'property_stock_supplier': fields.property(
'stock.location',
- type='many2one',
- relation='stock.location',
- string="Supplier Location",
+ type='many2one',
+ relation='stock.location',
+ string="Supplier Location",
method=True,
view_load=True,
help="This stock location will be used, instead of the default one, as the source location for goods you receive from the current partner"),
}
-res_partner()
+res_partner()
-
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
-
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
\ No newline at end of file
</record>
</data>
-</openerp>
+</openerp>
\ No newline at end of file
from osv import fields, osv
from tools.translate import _
-
class product_product(osv.osv):
_inherit = "product.product"
def get_product_accounts(self, cr, uid, product_id, context=None):
""" To get the stock input account, stock output account and stock journal related to product.
- @param product_id: product id
+ @param product_id: product id
@return: dictionary which contains information regarding stock input account, stock output account and stock journal
"""
- product_obj = self.pool.get('product.product').browse(cr, uid, product_id, context)
-
- stock_input_acc = product_obj.property_stock_account_input and product_obj.property_stock_account_input.id or False
+ if context is None:
+ context = {}
+ product_obj = self.pool.get('product.product').browse(cr, uid, product_id, context=context)
+
+ stock_input_acc = product_obj.property_stock_account_input and product_obj.property_stock_account_input.id or False
if not stock_input_acc:
stock_input_acc = product_obj.categ_id.property_stock_account_input_categ and product_obj.categ_id.property_stock_account_input_categ.id or False
-
+
stock_output_acc = product_obj.property_stock_account_output and product_obj.property_stock_account_output.id or False
if not stock_output_acc:
stock_output_acc = product_obj.categ_id.property_stock_account_output_categ and product_obj.categ_id.property_stock_account_output_categ.id or False
journal_id = product_obj.categ_id.property_stock_journal and product_obj.categ_id.property_stock_journal.id or False
account_variation = product_obj.categ_id.property_stock_variation and product_obj.categ_id.property_stock_variation.id or False
-
+
return {
- 'stock_account_input': stock_input_acc,
- 'stock_account_output': stock_output_acc,
- 'stock_journal': journal_id,
+ 'stock_account_input': stock_input_acc,
+ 'stock_account_output': stock_output_acc,
+ 'stock_journal': journal_id,
'property_stock_variation': account_variation
- }
+ }
def do_change_standard_price(self, cr, uid, ids, datas, context={}):
""" Changes the Standard Price of Product and creates an account move accordingly.
@param datas : dict. contain default datas like new_price, stock_output_account, stock_input_account, stock_journal
- @param context: A standard dictionary
- @return:
-
- """
+ @param context: A standard dictionary
+ @return:
+
+ """
location_obj = self.pool.get('stock.location')
move_obj = self.pool.get('account.move')
- move_line_obj = self.pool.get('account.move.line')
+ move_line_obj = self.pool.get('account.move.line')
new_price = datas.get('new_price', 0.0)
stock_output_acc = datas.get('stock_output_account', False)
account_variation = product_obj.categ_id.property_stock_variation
account_variation_id = account_variation and account_variation.id or False
if not account_variation_id: raise osv.except_osv(_('Error!'), _('Variation Account is not specified for Product Category: %s' % (product_obj.categ_id.name)))
- move_ids = []
+ move_ids = []
loc_ids = location_obj.search(cr, uid,[('usage','=','internal')])
for rec_id in ids:
for location in location_obj.browse(cr, uid, loc_ids):
c.update({
'location': location.id,
'compute_child': False
- })
-
+ })
+
product = self.browse(cr, uid, rec_id, context=c)
qty = product.qty_available
- diff = product.standard_price - new_price
+ diff = product.standard_price - new_price
if not diff: raise osv.except_osv(_('Error!'), _("Could not find any difference between standard price and new price!"))
if qty:
- company_id = location.company_id and location.company_id.id or False
+ company_id = location.company_id and location.company_id.id or False
if not company_id: raise osv.except_osv(_('Error!'), _('Company is not specified in Location'))
#
# Accounting Entries
(product.categ_id.name,
product.categ_id.id,))
move_id = move_obj.create(cr, uid, {
- 'journal_id': journal_id,
+ 'journal_id': journal_id,
'company_id': company_id
- })
-
+ })
+
move_ids.append(move_id)
'for this product: "%s" (id: %d)') % \
(product.name,
product.id,))
- amount_diff = qty * diff
+ amount_diff = qty * diff
move_line_obj.create(cr, uid, {
'name': product.name,
'account_id': stock_input_acc,
'credit': amount_diff,
'move_id': move_id
})
- elif diff < 0:
+ elif diff < 0:
if not stock_output_acc:
stock_output_acc = product.product_tmpl_id.\
property_stock_account_output.id
'account_id': account_variation_id,
'debit': amount_diff,
'move_id': move_id
- })
-
+ })
+
self.write(cr, uid, rec_id, {'standard_price': new_price})
return move_ids
- def view_header_get(self, cr, user, view_id, view_type, context):
+ def view_header_get(self, cr, user, view_id, view_type, context=None):
+ if context is None:
+ context = {}
res = super(product_product, self).view_header_get(cr, user, view_id, view_type, context)
if res: return res
if (context.get('location', False)):
res[prod_id] -= amount
return res
- def _product_available(self, cr, uid, ids, field_names=None, arg=False, context={}):
+ def _product_available(self, cr, uid, ids, field_names=None, arg=False, context=None):
""" Finds the incoming and outgoing quantity of product.
@return: Dictionary of values
"""
if not field_names:
field_names = []
+ if context is None:
+ context = {}
res = {}
for id in ids:
res[id] = {}.fromkeys(field_names, 0.0)
def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):
res = super(product_product,self).fields_view_get(cr, uid, view_id, view_type, context, toolbar=toolbar, submenu=submenu)
- if context == None:
+ if context is None:
context = {}
if ('location' in context) and context['location']:
location_info = self.pool.get('stock.location').browse(cr, uid, context['location'])
if location_info.usage == 'inventory':
if fields.get('virtual_available'):
res['fields']['virtual_available']['string'] = _('Future P&L')
- if fields.get('qty_available'):
+ if fields.get('qty_available'):
res['fields']['qty_available']['string'] = _('P&L Qty')
if location_info.usage == 'procurement':
res['fields']['virtual_available']['string'] = _('Future Productions')
if fields.get('qty_available'):
res['fields']['qty_available']['string'] = _('Produced Qty')
-
return res
-product_product()
+product_product()
class product_template(osv.osv):
_name = 'product.template'
string='Stock Output Account', method=True, view_load=True,
help='This account will be used, instead of the default one, to value output stock'),
}
-product_template()
+product_template()
class product_category(osv.osv):
+
_inherit = 'product.category'
_columns = {
'property_stock_journal': fields.property('account.journal',
type='many2one', relation='account.account',
string='Stock Output Account', method=True, view_load=True,
help='This account will be used to value the output stock'),
- 'property_stock_variation': fields.property('account.account',
+ 'property_stock_variation': fields.property('account.account',
type='many2one',
relation='account.account',
string="Stock Variation Account",
- method=True, view_load=True,
+ method=True, view_load=True,
help="This account will be used in product when valuation type is real-time valuation ",),
}
-product_category()
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+product_category()
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
\ No newline at end of file
<field eval="False" name="value"/>
<field name="company_id" ref="base.main_company"/>
</record>
-
+
</data>
-</openerp>
+</openerp>
\ No newline at end of file
_name = "stock.incoterms"
_description = "Incoterms"
_columns = {
- 'name': fields.char('Name', size=64, required=True,help="Incoterms are series of sales terms.They are used to divide transaction costs and responsibilities between buyer and seller and reflect state-of-the-art transportation practices."),
- 'code': fields.char('Code', size=3, required=True,help="Code for Incoterms"),
+ 'name': fields.char('Name', size=64, required=True, help="Incoterms are series of sales terms.They are used to divide transaction costs and responsibilities between buyer and seller and reflect state-of-the-art transportation practices."),
+ 'code': fields.char('Code', size=3, required=True, help="Code for Incoterms"),
'active': fields.boolean('Active', help="If the active field is set to true, it will allow you to hide the incoterms without removing it."),
}
_defaults = {
- 'active': lambda *a: True,
+ 'active': True,
}
stock_incoterms()
_description = "Stock Journal"
_columns = {
'name': fields.char('Stock Journal', size=32, required=True),
- 'user_id': fields.many2one('res.users','Responsible'),
+ 'user_id': fields.many2one('res.users', 'Responsible'),
}
_defaults = {
- 'user_id': lambda s,c,u,ctx: u
+ 'user_id': lambda s, c, u, ctx: u
}
+
stock_journal()
#----------------------------------------------------------
_parent_order = 'id'
_order = 'parent_left'
- def name_get(self, cr, uid, ids, context={}):
+ def name_get(self, cr, uid, ids, context=None):
+ res = []
+ if context is None:
+ context = {}
if not len(ids):
return []
- reads = self.read(cr, uid, ids, ['name','location_id'], context)
- res = []
+ reads = self.read(cr, uid, ids, ['name','location_id'], context=context)
for record in reads:
name = record['name']
if context.get('full',False):
if record['location_id']:
- name = record['location_id'][1]+' / '+name
+ name = record['location_id'][1] + ' / ' + name
res.append((record['id'], name))
else:
res.append((record['id'], name))
return res
- def _complete_name(self, cr, uid, ids, name, args, context):
+ def _complete_name(self, cr, uid, ids, name, args, context=None):
""" Forms complete name of location from parent location to child location.
@return: Dictionary of values
"""
res[m.id] = _get_one_full_name(m)
return res
- def _product_qty_available(self, cr, uid, ids, field_names, arg, context={}):
+ def _product_qty_available(self, cr, uid, ids, field_names, arg, context=None):
""" Finds real and virtual quantity for product available at particular location.
@return: Dictionary of values
"""
res[loc]['stock_virtual'] = prod.virtual_available
return res
- def product_detail(self, cr, uid, id, field, context={}):
+ def product_detail(self, cr, uid, id, field, context=None):
""" Finds detail of product like price type, currency and then calculates its price.
@param field: Field name
@return: Calculated price
res[id] = {}
final_value = 0.0
field_to_read = 'virtual_available'
+ if context is None:
+ context = {}
if field == 'stock_real_value':
field_to_read = 'qty_available'
cr.execute('select distinct product_id from stock_move where (location_id=%s) or (location_dest_id=%s)', (id, id))
# Choose the right filed standard_price to read
# Take the user company
price_type_id = self.pool.get('res.users').browse(cr,uid,uid).company_id.property_valuation_price_type.id
- pricetype = self.pool.get('product.price.type').browse(cr, uid, price_type_id)
+ pricetype = self.pool.get('product.price.type').browse(cr, uid, price_type_id, context=context)
for r in result:
c = (context or {}).copy()
c['location'] = id
product = self.pool.get('product.product').read(cr, uid, r['product_id'], [field_to_read], context=c)
# Compute the amount_unit in right currency
-
context['currency_id'] = self.pool.get('res.users').browse(cr,uid,uid).company_id.currency_id.id
amount_unit = self.pool.get('product.product').browse(cr,uid,r['product_id']).price_get(pricetype.field, context)[r['product_id']]
-
final_value += (product[field_to_read] * amount_unit)
return final_value
- def _product_value(self, cr, uid, ids, field_names, arg, context={}):
+ def _product_value(self, cr, uid, ids, field_names, arg, context=None):
""" Calculates real and virtual stock value of a product.
@param field_names: Name of field
@return: Dictionary of values
'scrap_location': fields.boolean('Scrap Location', help='Check this box if the current location is a place for destroyed items'),
}
_defaults = {
- 'active': lambda *a: 1,
- 'usage': lambda *a: 'internal',
- 'allocation_method': lambda *a: 'fifo',
- 'chained_location_type': lambda *a: 'none',
- 'chained_auto_packing': lambda *a: 'manual',
- 'company_id': lambda self,cr,uid,c: self.pool.get('res.company')._company_default_get(cr, uid, 'stock.location', context=c),
- 'posx': lambda *a: 0,
- 'posy': lambda *a: 0,
- 'posz': lambda *a: 0,
- 'icon': lambda *a: False,
- 'scrap_location': lambda *a: False,
+ 'active': True,
+ 'usage': 'internal',
+ 'allocation_method': 'fifo',
+ 'chained_location_type': 'none',
+ 'chained_auto_packing': 'manual',
+ 'company_id': lambda self, cr, uid, c: self.pool.get('res.company')._company_default_get(cr, uid, 'stock.location', context=c),
+ 'posx': 0,
+ 'posy': 0,
+ 'posz': 0,
+ 'icon': False,
+ 'scrap_location': False,
}
- def chained_location_get(self, cr, uid, location, partner=None, product=None, context={}):
+ def chained_location_get(self, cr, uid, location, partner=None, product=None, context=None):
""" Finds chained location
@param location: Location id
@param partner: Partner id
return result, location.chained_auto_packing, location.chained_delay, location.chained_journal_id and location.chained_journal_id.id or False, location.chained_company_id and location.chained_company_id.id or False, location.chained_picking_type
return result
- def picking_type_get(self, cr, uid, from_location, to_location, context={}):
+ def picking_type_get(self, cr, uid, from_location, to_location, context=None):
""" Gets type of picking.
@param from_location: Source location
@param to_location: Destination location
result = 'internal'
if (from_location.usage=='internal') and (to_location and to_location.usage in ('customer', 'supplier')):
result = 'delivery'
- elif (from_location.usage in ('supplier', 'customer')) and (to_location.usage=='internal'):
+ elif (from_location.usage in ('supplier', 'customer')) and (to_location.usage == 'internal'):
result = 'in'
return result
- def _product_get_all_report(self, cr, uid, ids, product_ids=False,
- context=None):
- return self._product_get_report(cr, uid, ids, product_ids, context,
- recursive=True)
+ def _product_get_all_report(self, cr, uid, ids, product_ids=False, context=None):
+ return self._product_get_report(cr, uid, ids, product_ids, context, recursive=True)
def _product_get_report(self, cr, uid, ids, product_ids=False,
context=None, recursive=False):
result['total_price'] = total_price
return result
- def _product_get_multi_location(self, cr, uid, ids, product_ids=False, context={},
+ def _product_get_multi_location(self, cr, uid, ids, product_ids=False, context=None,
states=['done'], what=('in', 'out')):
"""
@param product_ids: Ids of product
@return:
"""
product_obj = self.pool.get('product.product')
+ if context is None:
+ context = {}
context.update({
'states': states,
'what': what,
})
return product_obj.get_product_available(cr, uid, product_ids, context=context)
- def _product_get(self, cr, uid, id, product_ids=False, context={}, states=['done']):
+ def _product_get(self, cr, uid, id, product_ids=False, context=None, states=['done']):
"""
@param product_ids:
@param states:
@return:
"""
ids = id and [id] or []
- return self._product_get_multi_location(cr, uid, ids, product_ids, context, states)
+ return self._product_get_multi_location(cr, uid, ids, product_ids, context=context, states=states)
- def _product_all_get(self, cr, uid, id, product_ids=False, context={}, states=['done']):
+ def _product_all_get(self, cr, uid, id, product_ids=False, context=None, states=['done']):
# build the list of ids of children of the location given by id
ids = id and [id] or []
location_ids = self.search(cr, uid, [('location_id', 'child_of', ids)])
return self._product_get_multi_location(cr, uid, location_ids, product_ids, context, states)
- def _product_virtual_get(self, cr, uid, id, product_ids=False, context={}, states=['done']):
+ def _product_virtual_get(self, cr, uid, id, product_ids=False, context=None, states=['done']):
return self._product_all_get(cr, uid, id, product_ids, context, ['confirmed', 'waiting', 'assigned', 'done'])
#
# Returns:
# [ (tracking_id, product_qty, location_id) ]
#
- def _product_reserve(self, cr, uid, ids, product_id, product_qty, context={}):
+ def _product_reserve(self, cr, uid, ids, product_id, product_qty, context=None):
"""
@param product_id: Id of product
@param product_qty: Quantity of product
"""
result = []
amount = 0.0
+ if context is None:
+ context = {}
for id in self.search(cr, uid, [('location_id', 'child_of', ids)]):
cr.execute("select product_uom,sum(product_qty) as product_qty from stock_move where location_dest_id=%s and location_id<>%s and product_id=%s and state='done' group by product_uom", (id, id, product_id))
results = cr.dictfetchall()
return (10 - (sum % 10)) % 10
checksum = staticmethod(checksum)
- def make_sscc(self, cr, uid, context={}):
+ def make_sscc(self, cr, uid, context=None):
sequence = self.pool.get('ir.sequence').get(cr, uid, 'stock.lot.tracking')
return sequence + str(self.checksum(sequence))
'date': fields.datetime('Created Date', required=True),
}
_defaults = {
- 'active': lambda *a: 1,
+ 'active': 1,
'name': make_sscc,
- 'date': lambda *a: time.strftime('%Y-%m-%d %H:%M:%S'),
+ 'date': time.strftime('%Y-%m-%d %H:%M:%S'),
}
def name_search(self, cr, user, name, args=None, operator='ilike', context=None, limit=100):
ids += self.search(cr, user, [('name', operator, name)]+ args, limit=limit, context=context)
return self.name_get(cr, user, ids, context)
- def name_get(self, cr, uid, ids, context={}):
+ def name_get(self, cr, uid, ids, context=None):
if not len(ids):
return []
res = [(r['id'], r['name']+' ['+(r['serial'] or '')+']') for r in self.read(cr, uid, ids, ['name', 'serial'], context)]
stock_tracking()
-
#----------------------------------------------------------
# Stock Picking
#----------------------------------------------------------
_name = "stock.picking"
_description = "Picking List"
- def _set_maximum_date(self, cr, uid, ids, name, value, arg, context):
+ def _set_maximum_date(self, cr, uid, ids, name, value, arg, context=None):
""" Calculates planned date if it is greater than 'value'.
@param name: Name of field
@param value: Value of field
cr.execute(sql_str)
return True
- def _set_minimum_date(self, cr, uid, ids, name, value, arg, context):
+ def _set_minimum_date(self, cr, uid, ids, name, value, arg, context=None):
""" Calculates planned date if it is less than 'value'.
@param name: Name of field
@param value: Value of field
return False
if isinstance(ids, (int, long)):
ids = [ids]
- for pick in self.browse(cr, uid, ids, context):
+ for pick in self.browse(cr, uid, ids, context=context):
sql_str = """update stock_move set
date_planned='%s'
where
cr.execute(sql_str)
return True
- def get_min_max_date(self, cr, uid, ids, field_name, arg, context={}):
+ def get_min_max_date(self, cr, uid, ids, field_name, arg, context=None):
""" Finds minimum and maximum dates for picking.
@return: Dictionary of values
"""
}
_defaults = {
'name': lambda self, cr, uid, context: '/',
- 'active': lambda *a: 1,
- 'state': lambda *a: 'draft',
- 'move_type': lambda *a: 'direct',
- 'type': lambda *a: 'in',
- 'invoice_state': lambda *a: 'none',
- 'date': lambda *a: time.strftime('%Y-%m-%d %H:%M:%S'),
- 'company_id': lambda self,cr,uid,c: self.pool.get('res.company')._company_default_get(cr, uid, 'stock.picking', context=c)
+ 'active': 1,
+ 'state': 'draft',
+ 'move_type': 'direct',
+ 'type': 'in',
+ 'invoice_state': 'none',
+ 'date': time.strftime('%Y-%m-%d %H:%M:%S'),
+ 'company_id': lambda self, cr, uid, c: self.pool.get('res.company')._company_default_get(cr, uid, 'stock.picking', context=c)
}
- def copy(self, cr, uid, id, default=None, context={}):
+ def copy(self, cr, uid, id, default=None, context=None):
if default is None:
default = {}
default = default.copy()
if ('name' not in default) or (picking_obj.name=='/'):
seq_obj_name = 'stock.picking.' + picking_obj.type
default['name'] = self.pool.get('ir.sequence').get(cr, uid, seq_obj_name)
-
return super(stock_picking, self).copy(cr, uid, id, default, context)
- def onchange_partner_in(self, cr, uid, context, partner_id=None):
+ def onchange_partner_in(self, cr, uid, context=None, partner_id=None):
return {}
- def action_explode(self, cr, uid, moves, context={}):
+ def action_explode(self, cr, uid, moves, context=None):
return moves
- def action_confirm(self, cr, uid, ids, context={}):
+ def action_confirm(self, cr, uid, ids, context=None):
""" Confirms picking.
@return: True
"""
todo.append(r.id)
todo = self.action_explode(cr, uid, todo, context)
if len(todo):
- self.pool.get('stock.move').action_confirm(cr, uid, todo, context)
+ self.pool.get('stock.move').action_confirm(cr, uid, todo, context=context)
return True
def test_auto_picking(self, cr, uid, ids):
ok = ok and (move.state in ('cancel', 'done', 'assigned'))
return ok
- def action_cancel(self, cr, uid, ids, context={}):
+ def action_cancel(self, cr, uid, ids, context=None):
""" Changes picking state to cancel.
@return: True
"""
self.write(cr, uid, ids, {'state': 'done', 'date_done': time.strftime('%Y-%m-%d %H:%M:%S')})
return True
- def action_move(self, cr, uid, ids, context={}):
+ def action_move(self, cr, uid, ids, context=None):
""" Changes move state to assigned.
@return: True
"""
for move in pick.move_lines:
if move.state == 'assigned':
todo.append(move.id)
-
if len(todo):
self.pool.get('stock.move').action_done(cr, uid, todo,
context=context)
}, context=context)
return res
- def test_done(self, cr, uid, ids, context={}):
+ def test_done(self, cr, uid, ids, context=None):
ok = False
for pick in self.browse(cr, uid, ids, context=context):
if not pick.move_lines:
ok = True
return ok
- def test_cancel(self, cr, uid, ids, context={}):
+ def test_cancel(self, cr, uid, ids, context=None):
""" Test whether the move lines are canceled or not.
@return: True or False
"""
move_obj = self.pool.get('stock.move')
if not context:
context = {}
-
for pick in self.browse(cr, uid, ids, context=context):
if pick.state in ['done','cancel']:
raise osv.except_osv(_('Error'), _('You cannot remove the picking which is in %s state !')%(pick.state,))
return super(stock_picking, self).unlink(cr, uid, ids, context=context)
- def do_partial(self, cr, uid, ids, partial_datas, context={}):
+ def do_partial(self, cr, uid, ids, partial_datas, context=None):
""" Makes partial picking and moves done.
@param partial_datas : Dictionary containing details of partial picking
like partner_id, address_id, delivery_date,
@return: Dictionary of values
"""
res = {}
-
move_obj = self.pool.get('stock.move')
product_obj = self.pool.get('product.product')
currency_obj = self.pool.get('res.currency')
for pick in self.browse(cr, uid, ids, context=context):
new_picking = None
new_moves = []
-
complete, too_many, too_few = [], [], []
move_product_qty = {}
for move in pick.move_lines:
delivered_pack = self.browse(cr, uid, delivered_pack_id, context=context)
res[pick.id] = {'delivered_picking': delivered_pack.id or False}
+
return res
stock_picking()
-
class stock_production_lot(osv.osv):
- def name_get(self, cr, uid, ids, context={}):
+
+ def name_get(self, cr, uid, ids, context=None):
if not ids:
return []
reads = self.read(cr, uid, ids, ['name', 'prefix', 'ref'], context)
_name = 'stock.production.lot'
_description = 'Production lot'
- def _get_stock(self, cr, uid, ids, field_name, arg, context={}):
+ def _get_stock(self, cr, uid, ids, field_name, arg, context=None):
""" Gets stock of products for locations
@return: Dictionary of values
"""
where
location_id IN %s and prodlot_id IN %s group by prodlot_id''',(tuple(locations),tuple(ids),))
res.update(dict(cr.fetchall()))
+
return res
- def _stock_search(self, cr, uid, obj, name, args, context):
+ def _stock_search(self, cr, uid, obj, name, args, context=None):
""" Searches Ids of products
@return: Ids of locations
"""
'company_id': fields.many2one('res.company','Company',select=1),
}
_defaults = {
- 'date': lambda *a: time.strftime('%Y-%m-%d %H:%M:%S'),
+ 'date': time.strftime('%Y-%m-%d %H:%M:%S'),
'name': lambda x, y, z, c: x.pool.get('ir.sequence').get(y, z, 'stock.lot.serial'),
'product_id': lambda x, y, z, c: c.get('product_id', False),
}
_defaults = {
'author_id': lambda x, y, z, c: z,
- 'date': lambda *a: time.strftime('%Y-%m-%d'),
+ 'date': time.strftime('%Y-%m-%d'),
}
stock_production_lot_revision()
#
class stock_move(osv.osv):
- def _getSSCC(self, cr, uid, context={}):
+ def _getSSCC(self, cr, uid, context=None):
cr.execute('select id from stock_tracking where create_uid=%s order by id desc limit 1', (uid,))
res = cr.fetchone()
return (res and res[0]) or False
_order = 'date_expected desc, id'
_log_create = False
- def name_get(self, cr, uid, ids, context={}):
+ def name_get(self, cr, uid, ids, context=None):
res = []
for line in self.browse(cr, uid, ids, context):
res.append((line.id, (line.product_id.code or '/')+': '+line.location_id.name+' > '+line.location_dest_id.name))
'You try to assign a lot which is not from the same product',
['prodlot_id'])]
- def _default_location_destination(self, cr, uid, context={}):
+ def _default_location_destination(self, cr, uid, context=None):
""" Gets default address of partner for destination location
@return: Address id or False
"""
return property_out and property_out.id or False
return False
- def _default_location_source(self, cr, uid, context={}):
+ def _default_location_source(self, cr, uid, context=None):
""" Gets default address of partner for source location
@return: Address id or False
"""
_defaults = {
'location_id': _default_location_source,
'location_dest_id': _default_location_destination,
- 'state': lambda *a: 'draft',
- 'priority': lambda *a: '1',
- 'product_qty': lambda *a: 1.0,
- 'scraped' : lambda *a: False,
- 'date_planned': lambda *a: time.strftime('%Y-%m-%d %H:%M:%S'),
- 'date': lambda *a: time.strftime('%Y-%m-%d %H:%M:%S'),
+ 'state': 'draft',
+ 'priority': '1',
+ 'product_qty': 1.0,
+ 'scraped' : False,
+ 'date_planned': time.strftime('%Y-%m-%d %H:%M:%S'),
+ 'date': time.strftime('%Y-%m-%d %H:%M:%S'),
'company_id': lambda self,cr,uid,c: self.pool.get('res.company')._company_default_get(cr, uid, 'stock.move', context=c),
- 'date_expected': lambda *a: time.strftime('%Y-%m-%d %H:%M:%S'),
+ 'date_expected': time.strftime('%Y-%m-%d %H:%M:%S'),
}
- def copy(self, cr, uid, id, default=None, context={}):
+ def copy(self, cr, uid, id, default=None, context=None):
if default is None:
default = {}
default = default.copy()
- return super(stock_move, self).copy(cr, uid, id, default, context)
+ return super(stock_move, self).copy(cr, uid, id, default, context=context)
- def _auto_init(self, cursor, context):
- res = super(stock_move, self)._auto_init(cursor, context)
+ def _auto_init(self, cursor, context=None):
+ res = super(stock_move, self)._auto_init(cursor, context=context)
cursor.execute('SELECT indexname \
FROM pg_indexes \
WHERE indexname = \'stock_move_location_id_location_dest_id_product_id_state\'')
result['location_dest_id'] = loc_dest_id
return {'value': result}
- def _chain_compute(self, cr, uid, moves, context={}):
+ def _chain_compute(self, cr, uid, moves, context=None):
""" Finds whether the location has chained location type or not.
@param moves: Stock moves
@return: Dictionary containing destination location with chained location type.
result[m.picking_id].append( (m, dest) )
return result
- def action_confirm(self, cr, uid, ids, context={}):
+ def action_confirm(self, cr, uid, ids, context=None):
""" Confirms stock move.
@return: List of ids.
"""
self.write(cr, uid, ids, {'state': 'confirmed'})
i = 0
- def create_chained_picking(self, cr, uid, moves, context):
+ def create_chained_picking(self, cr, uid, moves, context=None):
new_moves = []
res_obj = self.pool.get('res.company')
- for picking, todo in self._chain_compute(cr, uid, moves, context).items():
+ if context is None:
+ context = {}
+ for picking, todo in self._chain_compute(cr, uid, moves, context=context).items():
ptype = todo[0][1][5] and todo[0][1][5] or self.pool.get('stock.location').picking_type_get(cr, uid, todo[0][0].location_dest_id, todo[0][1][0])
pick_name = ''
if ptype == 'delivery':
#
# Duplicate stock.move
#
- def check_assign(self, cr, uid, ids, context={}):
+ def check_assign(self, cr, uid, ids, context=None):
""" Checks the product type and accordingly writes the state.
@return: No. of moves done
"""
done = []
count = 0
pickings = {}
+ if context is None:
+ context = {}
for move in self.browse(cr, uid, ids, context=context):
if move.product_id.type == 'consu':
if move.state in ('confirmed', 'waiting'):
#
# Cancel move => cancel others move and pickings
#
- def action_cancel(self, cr, uid, ids, context={}):
+ def action_cancel(self, cr, uid, ids, context=None):
""" Cancels the moves and if all moves are cancelled it cancels the picking.
@return: True
"""
if not len(ids):
return True
+ if context is None:
+ context = {}
pickings = {}
for move in self.browse(cr, uid, ids):
if move.state in ('confirmed', 'waiting', 'assigned', 'draft'):
acc_variation = accounts['property_stock_variation']
journal_id = accounts['stock_journal']
+ if context is None:
+ context = {}
+
if not acc_src:
raise osv.except_osv(_('Error!'), _('There is no stock input account defined ' \
'for this product: "%s" (id: %d)') % \
# amount = q * move.product_id.standard_price
return journal_id, acc_src, acc_dest, acc_variation, amount
-
- def action_done(self, cr, uid, ids, context={}):
+ def action_done(self, cr, uid, ids, context=None):
""" Makes the move done and if all moves are done, it will finish the picking.
@return:
"""
picking_ids = []
product_uom_obj = self.pool.get('product.uom')
price_type_obj = self.pool.get('product.price.type')
- product_obj=self.pool.get('product.product')
+ product_obj = self.pool.get('product.product')
move_obj = self.pool.get('account.move')
+ if context is None:
+ context = {}
for move in self.browse(cr, uid, ids):
if move.picking_id:
picking_ids.append(move.picking_id.id)
for (id,name) in picking_obj.name_get(cr, uid, picking_ids):
message = _('Document') + " '" + name + "' "+ _("is processed")
self.log(cr, uid, id, message)
-
return True
- def create_account_move(self, cr, uid, move,account_id,account_variation,amount, context=None):
-
+ def create_account_move(self, cr, uid, move,account_id, account_variation, amount, context=None):
+ if context is None:
+ context = {}
partner_id = move.picking_id.address_id and (move.picking_id.address_id.partner_id and move.picking_id.address_id.partner_id.id or False) or False
lines=[(0, 0, {
'name': move.name,
@return: Splited move lines
"""
+ if context is None:
+ context = {}
if quantity <= 0:
raise osv.except_osv(_('Warning!'), _('Please provide Proper Quantity !'))
"""
if context is None:
context = {}
-
if quantity <= 0:
raise osv.except_osv(_('Warning!'), _('Please provide Proper Quantity !'))
else:
current_move = self.copy(cr, uid, move.id, default_val)
res += [current_move]
-
update_val = {}
update_val['product_qty'] = quantity_rest
update_val['product_uos_qty'] = uos_qty_rest
else:
quantity_rest = quantity
uos_qty_rest = uos_qty
-
if move.product_id.track_production and location_id:
res += self.split_lines(cr, uid, [move.id], quantity_rest, split_by_qty=1, context=context)
else:
}
self.write(cr, uid, [move.id], update_val)
-
self.action_done(cr, uid, res)
+
return res
- def do_partial(self, cr, uid, ids, partial_datas, context={}):
+ def do_partial(self, cr, uid, ids, partial_datas, context=None):
""" Makes partial pickings and moves done.
@param partial_datas: Dictionary containing details of partial picking
like partner_id, address_id, delivery_date, delivery
partner_id = partial_datas.get('partner_id', False)
address_id = partial_datas.get('address_id', False)
delivery_date = partial_datas.get('delivery_date', False)
-
new_moves = []
+ if context is None:
+ context = {}
+
complete, too_many, too_few = [], [], []
move_product_qty = {}
for move in self.browse(cr, uid, ids, context=context):
complete.append(move)
for move in complete:
- self.action_done(cr, uid, [move.id], context)
+ self.action_done(cr, uid, [move.id], context=context)
if move.picking_id.id :
# TOCHECK : Done picking if all moves are done
cr.execute("""
stock_move()
-
class stock_inventory(osv.osv):
_name = "stock.inventory"
_description = "Inventory"
'company_id': fields.many2one('res.company','Company',required=True,select=1),
}
_defaults = {
- 'date': lambda *a: time.strftime('%Y-%m-%d %H:%M:%S'),
- 'state': lambda *a: 'draft',
+ 'date': time.strftime('%Y-%m-%d %H:%M:%S'),
+ 'state': 'draft',
'company_id': lambda self,cr,uid,c: self.pool.get('res.company')._company_default_get(cr, uid, 'stock.inventory', context=c)
}
-
def _inventory_line_hook(self, cr, uid, inventory_line, move_vals):
""" Creates a stock move from an inventory line
@param inventory_line:
""" Finishes the inventory and writes its finished date
@return: True
"""
+ if context is None:
+ context = {}
for inv in self.browse(cr, uid, ids):
move_ids = []
move_line = []
self.write(cr, uid, [inv.id], {'state': 'done', 'date_done': time.strftime('%Y-%m-%d %H:%M:%S'), 'move_ids': [(6, 0, move_ids)]})
return True
- def action_cancel(self, cr, uid, ids, context={}):
+ def action_cancel(self, cr, uid, ids, context=None):
""" Cancels the stock move and change inventory state to draft.
@return: True
"""
self.write(cr, uid, [inv.id], {'state': 'draft'})
return True
- def action_cancel_inventary(self, cr, uid, ids, context={}):
+ def action_cancel_inventary(self, cr, uid, ids, context=None):
""" Cancels both stock move and inventory
@return: True
"""
stock_inventory()
-
class stock_inventory_line(osv.osv):
_name = "stock.inventory.line"
_description = "Inventory Line"
stock_inventory_line()
-
#----------------------------------------------------------
# Stock Warehouse
#----------------------------------------------------------
'lot_output_id': fields.many2one('stock.location', 'Location Output', required=True, domain=[('usage','<>','view')]),
}
_defaults = {
- 'company_id': lambda self,cr,uid,c: self.pool.get('res.company')._company_default_get(cr, uid, 'stock.inventory', context=c),
+ 'company_id': lambda self, cr, uid, c: self.pool.get('res.company')._company_default_get(cr, uid, 'stock.inventory', context=c),
}
+
stock_warehouse()
class stock_picking_move_wizard(osv.osv_memory):
_name = 'stock.picking.move.wizard'
- def _get_picking(self, cr, uid, ctx):
+ def _get_picking(self, cr, uid, ctx=None):
+ if ctx is None:
+ ctx = {}
if ctx.get('action_id', False):
return ctx['action_id']
return False
- def _get_picking_address(self, cr, uid, ctx):
+ def _get_picking_address(self, cr, uid, context=None):
picking_obj = self.pool.get('stock.picking')
- if ctx.get('action_id', False):
- picking = picking_obj.browse(cr, uid, [ctx['action_id']])[0]
+ if context is None:
+ context = {}
+ if context.get('action_id', False):
+ picking = picking_obj.browse(cr, uid, [context['action_id']])[0]
return picking.address_id and picking.address_id.id or False
return False
'planned_qty': fields.integer('Planned Qty'),
}
-
def init(self, cr):
tools.drop_view_if_exists(cr, 'report_products_to_received_planned')
cr.execute("""
group by stock.date_planned
)
""")
+
report_products_to_received_planned()
class report_delivery_products_planned(osv.osv):
)
""")
+
report_delivery_products_planned()
+
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
+
<menuitem icon="terp-stock" id="menu_stock_root" name="Warehouse" sequence="5"/>
<menuitem id="menu_stock_warehouse_mgmt" name="Warehouse Management" parent="menu_stock_root" sequence="1"/>
<menuitem id="menu_stock_products_moves" name="Products Moves" parent="menu_stock_root" sequence="2"/>
<field name="state"/>
</tree>
</field>
-
</record>
+
<record id="view_inventory_form" model="ir.ui.view">
<field name="name">stock.inventory.form</field>
<field name="model">stock.inventory</field>
</form>
</field>
</record>
+
<record id="action_inventory_form" model="ir.actions.act_window">
<field name="name">Periodical Inventory</field>
<field name="type">ir.actions.act_window</field>
<button
name="%(stock.track_line)d"
string="Split in production lots"
- groups="base.group_extended"
+ groups="base.group_extended"
type="action" icon="terp-stock_effects-object-colorize"
states="draft,waiting,confirmed,assigned" />
<field groups="base.group_extended" name="tracking_id"/>
<button name="setlast_tracking" string="Put in current pack" type="object"
- attrs="{'invisible': [('tracking_id','<>',False)]}"
- icon="terp-stock_effects-object-colorize"
- groups="base.group_extended"
+ attrs="{'invisible': [('tracking_id','<>',False)]}"
+ icon="terp-stock_effects-object-colorize"
+ groups="base.group_extended"
states="draft,assigned,confirmed,done"/>
<button name="%(split_into)d" string="Put in a new pack" type="action"
- groups="base.group_extended"
- icon="terp-stock_effects-object-colorize"
+ groups="base.group_extended"
+ icon="terp-stock_effects-object-colorize"
states="draft,assigned,confirmed,done"/>
<field name="location_id"/>
<field name="location_dest_id"/>
<newline/>
<label/>
- <button name="%(track_line)d" string="Split in production lots"
+ <button name="%(track_line)d" string="Split in production lots"
states="draft,waiting,confirmed,assigned"
type="action" icon="terp-stock_effects-object-colorize"
groups="base.group_extended" />
<button name="%(move_scrap)d" string="Scrap" type="action" icon="gtk-justify-fill"/>
<button name="%(split_into)d" string="Put in a new pack" type="action"
states="draft,assigned,confirmed,done"
- groups="base.group_extended"
+ groups="base.group_extended"
icon="terp-stock_effects-object-colorize" />
<separator colspan="4" string="Move State"/>
<field name="state"/>
<field name="prodlot_id" groups="base.group_extended"/>
<field groups="base.group_extended" name="tracking_id"/>
<button name="setlast_tracking" string="Put in current pack" type="object"
- attrs="{'invisible': [('tracking_id','<>',False)]}"
- groups="base.group_extended"
- icon="terp-stock_effects-object-colorize"
+ attrs="{'invisible': [('tracking_id','<>',False)]}"
+ groups="base.group_extended"
+ icon="terp-stock_effects-object-colorize"
states="draft,assigned,confirmed,done"/>
<button name="%(split_into)d" string="Put in a new pack" type="action"
icon="terp-stock_effects-object-colorize"
<field groups="base.group_extended" name="tracking_id"/>
<label/>
- <button name="%(track_line)d" string="Split in production lots"
- groups="base.group_extended"
+ <button name="%(track_line)d" string="Split in production lots"
+ groups="base.group_extended"
states="draft,waiting,confirmed,assigned"
type="action" icon="terp-stock_effects-object-colorize"/>
<label/>
<button name="%(split_into)d" string="Put in a new pack" type="action"
- groups="base.group_extended"
+ groups="base.group_extended"
icon="terp-stock_effects-object-colorize"
states="draft,assigned,confirmed,done"/>
<separator colspan="4" string="Move State"/>
groups="base.group_extended"/>
<field name="tracking_id" groups="base.group_extended"/>
<button name="setlast_tracking" string="Put in current pack" type="object"
- attrs="{'invisible': [('tracking_id','<>',False)]}"
- groups="base.group_extended"
- icon="terp-stock_effects-object-colorize"
+ attrs="{'invisible': [('tracking_id','<>',False)]}"
+ groups="base.group_extended"
+ icon="terp-stock_effects-object-colorize"
states="draft,assigned,confirmed,done"/>
<button name="%(split_into)d" string="Put in a new pack" type="action"
icon="terp-stock_effects-object-colorize"
- groups="base.group_extended"
+ groups="base.group_extended"
states="draft,assigned,confirmed,done"/>
<field name="location_id"/>
<field name="date_planned"/>
<label/>
<button name="%(track_line)d" string="Split in production lots" type="action" icon="terp-stock_effects-object-colorize"
states="draft,assigned,confirmed,done"
- groups="base.group_extended"
+ groups="base.group_extended"
/>
<label/>
<button name="%(split_into)d" string="Put in a new pack" type="action"
- groups="base.group_extended"
- icon="terp-stock_effects-object-colorize"
+ groups="base.group_extended"
+ icon="terp-stock_effects-object-colorize"
states="draft,assigned,confirmed,done"/>
<label/>
<separator colspan="4" string="Move State"/>
states="draft,waiting,confirmed,assigned" />
<field name="tracking_id" groups="base.group_extended"/>
<button name="setlast_tracking" string="Put in current pack" type="object"
- groups="base.group_extended"
+ groups="base.group_extended"
icon="terp-stock_effects-object-colorize" attrs="{'invisible': [('tracking_id','<>',False)]}"
states="draft,assigned,confirmed,done"/>
<button name="%(split_into)d" string="Put in a new pack" type="action"
- groups="base.group_extended"
+ groups="base.group_extended"
icon="terp-stock_effects-object-colorize"
states="draft,assigned,confirmed,done"/>
<field name="state"/>
<button groups="base.group_extended" name="267" string="Split in production lots" type="action" icon="terp-stock_effects-object-colorize"/>
<label/>
<button name="275" string="Split Stock Moves" type="action"
- groups="base.group_extended"
+ groups="base.group_extended"
icon="terp-stock_effects-object-colorize" attrs="{'invisible': [('tracking_id','<>',False)]}" states="draft,assigned,confirmed,done"/>
<separator colspan="4" string="Move State"/>
<field name="state"/>
states="draft,waiting,confirmed,assigned" />
<field name="prodlot_id" groups="base.group_extended"/>
<button name="%(track_line)d" string="Split in Production Lots" type="action"
- icon="gtk-justify-fill"
+ icon="gtk-justify-fill"
states="draft,waiting,confirmed,assigned"
groups="base.group_extended"/>
<field groups="base.group_extended" name="tracking_id"/>
<button name="setlast_tracking" string="Put in current pack" type="object"
- groups="base.group_extended"
+ groups="base.group_extended"
icon="terp-stock_effects-object-colorize" attrs="{'invisible': [('tracking_id','<>',False)]}"
states="draft,assigned,confirmed,done"/>
<button name="%(split_into)d" string="Put in a new pack" type="action"
- groups="base.group_extended"
+ groups="base.group_extended"
icon="terp-stock_effects-object-colorize"
states="draft,assigned,confirmed,done"/>
<field name="location_id"/>
<group colspan="4" col="4">
<label/>
<button name="%(track_line)d"
- groups="base.group_extended"
+ groups="base.group_extended"
states="draft,waiting,confirmed,assigned"
string="Split in production lots" type="action" icon="terp-stock_effects-object-colorize" colspan="2" />
<label/>
<button name="%(split_into)d" string="Put in a new pack" type="action"
- groups="base.group_extended"
+ groups="base.group_extended"
icon="terp-stock_effects-object-colorize"
states="draft,assigned,confirmed,done"/>
</group>
groups="base.group_extended"/>
<field name="tracking_id" groups="base.group_extended"/>
<button name="setlast_tracking" string="Put in current pack" type="object"
- attrs="{'invisible': [('tracking_id','<>',False)]}"
- groups="base.group_extended"
- icon="terp-stock_effects-object-colorize"
+ attrs="{'invisible': [('tracking_id','<>',False)]}"
+ groups="base.group_extended"
+ icon="terp-stock_effects-object-colorize"
states="draft,assigned,confirmed,done"/>
<button name="%(split_into)d" string="Put in a new pack" type="action"
- groups="base.group_extended"
+ groups="base.group_extended"
icon="terp-stock_effects-object-colorize"
states="draft,assigned,confirmed,done"/>
<field name="date_planned"/>
<field groups="base.group_extended" name="tracking_id"/>
<newline/>
<label/>
- <button name="%(track_line)d" string="Split in production lots"
+ <button name="%(track_line)d" string="Split in production lots"
states="draft,waiting,confirmed,assigned"
- groups="base.group_extended"
+ groups="base.group_extended"
type="action" icon="terp-stock_effects-object-colorize"/>
<label/>
<button name="%(split_into)d" string="Put in a new pack" type="action"
- groups="base.group_extended"
+ groups="base.group_extended"
icon="terp-stock_effects-object-colorize"
states="draft,assigned,confirmed,done"/>
<label/>
- <button name="%(track_line)d" string="Split in production lots"
- groups="base.group_extended"
+ <button name="%(track_line)d" string="Split in production lots"
+ groups="base.group_extended"
type="action" icon="terp-stock_effects-object-colorize"/>
<separator colspan="4" string="Move State"/>
<field name="state"/>
parent="menu_warehouse_config" />
</data>
-</openerp>
+</openerp>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<openerp>
- <data>
-
- <!--
- <wizard string="UPS xml file" model="stock.move.lot" name="stock.ups_xml" />
- -->
-
- <wizard
- id="split_inventory_lots"
- model="stock.inventory.line"
- multi="True"
- name="stock.inventory.line.split"
- string="Split inventory lines"/>
- </data>
-</openerp>
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
+
<record id="wkf_picking" model="workflow">
<field name="name">stock.picking.basic</field>
<field name="osv">stock.picking</field>
<field name="kind">function</field>
<field name="action">action_cancel()</field>
</record>
-
+
<record id="act_cancel" model="workflow.activity">
<field name="wkf_id" ref="wkf_picking"/>
<field name="name">cancel</field>
<field name="kind">function</field>
<field name="action">action_cancel()</field>
</record>
-
+
<record id="trans_draft_confirmed" model="workflow.transition">
<field name="act_from" ref="act_draft"/>
<field name="act_to" ref="act_confirmed"/>
<field name="act_to" ref="act_cancel"/>
<field name="condition">test_cancel()</field>
</record>
+
</data>
</openerp>