Developed the get move wizard on a picking:
* list moves from the same partner and picking type that are confirmed or assigned * assign this move to the current picking * if the pickings where these moves come from are empty, close it (action done) Improved query_get in account_move_line.py to analyse only on draft or posted or all (posted+draft) moves. Improved all reporting wizards( like : general ledger report , partner balance report , account balance report , aged trial balance report , third party ledger report) to add a selection asking on draft or posted or all. - Defaults to all UOM Purchase: On change on the normal UOM if not in same category, to change the uom_po_id and set it equals to the UoM ! bzr revid: hmo@tinyerp.com-20080730062944-y190mq4zo5yhby8x
This commit is contained in:
parent
4596ba9353
commit
7481073ff2
|
@ -44,11 +44,17 @@ class account_move_line(osv.osv):
|
|||
fiscalyear_clause = (','.join([str(x) for x in fiscalyear_ids])) or '0'
|
||||
else:
|
||||
fiscalyear_clause = '%s' % context['fiscalyear']
|
||||
state=context.get('state',False)
|
||||
where_move_state=''
|
||||
if state:
|
||||
if state.lower() not in ['all']:
|
||||
where_move_state= " AND "+obj+".move_id in (select id from account_move where account_move.state = '"+state+"')"
|
||||
|
||||
if context.get('periods', False):
|
||||
ids = ','.join([str(x) for x in context['periods']])
|
||||
return obj+".active AND "+obj+".state<>'draft' AND "+obj+".period_id in (SELECT id from account_period WHERE fiscalyear_id in (%s) AND id in (%s))" % (fiscalyear_clause, ids)
|
||||
ids = ','.join([str(x) for x in context['periods']])
|
||||
return obj+".active AND "+obj+".state<>'draft' AND "+obj+".period_id in (SELECT id from account_period WHERE fiscalyear_id in (%s) AND id in (%s)) %s" % (fiscalyear_clause, ids,where_move_state)
|
||||
else:
|
||||
return obj+".active AND "+obj+".state<>'draft' AND "+obj+".period_id in (SELECT id from account_period WHERE fiscalyear_id in (%s))" % (fiscalyear_clause,)
|
||||
return obj+".active AND "+obj+".state<>'draft' AND "+obj+".period_id in (SELECT id from account_period WHERE fiscalyear_id in (%s) %s)" % (fiscalyear_clause,where_move_state)
|
||||
|
||||
def default_get(self, cr, uid, fields, context={}):
|
||||
data = self._default_get(cr, uid, fields, context)
|
||||
|
|
|
@ -87,6 +87,7 @@ class account_balance(report_sxw.rml_parse):
|
|||
ctx['fiscalyear'] = form['fiscalyear']
|
||||
ctx['periods'] = form['periods'][0][2]
|
||||
ctx['target_move'] = form['target_move']
|
||||
ctx['state']=form['state']
|
||||
accounts = self.pool.get('account.account').browse(self.cr, self.uid, ids, ctx)
|
||||
def cmp_code(x, y):
|
||||
return cmp(x.code, y.code)
|
||||
|
|
|
@ -53,7 +53,7 @@ class aged_trial_report(report_sxw.rml_parse):
|
|||
res = []
|
||||
account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line')
|
||||
line_query = account_move_line_obj._query_get(self.cr, self.uid, obj='line',
|
||||
context={'fiscalyear': form['fiscalyear']})
|
||||
context={'fiscalyear': form['fiscalyear'],'state':form['state']})
|
||||
self.cr.execute("SELECT DISTINCT res_partner.id AS id, " \
|
||||
"res_partner.name AS name, res_partner.ref AS code " \
|
||||
"FROM res_partner, account_move_line AS line, account_account " \
|
||||
|
@ -128,7 +128,7 @@ class aged_trial_report(report_sxw.rml_parse):
|
|||
def _get_total(self, fiscalyear, company_id):
|
||||
account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line')
|
||||
line_query = account_move_line_obj._query_get(self.cr, self.uid, obj='line',
|
||||
context={'fiscalyear': fiscalyear})
|
||||
context={'fiscalyear': fiscalyear,'state':self.datas['form']['state']})
|
||||
self.cr.execute("SELECT SUM(debit - credit) " \
|
||||
"FROM account_move_line AS line, account_account " \
|
||||
"WHERE (line.account_id = account_account.id) " \
|
||||
|
@ -145,7 +145,7 @@ class aged_trial_report(report_sxw.rml_parse):
|
|||
def _get_before(self, date, fiscalyear, company_id):
|
||||
account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line')
|
||||
line_query = account_move_line_obj._query_get(self.cr, self.uid, obj='line',
|
||||
context={'fiscalyear': fiscalyear})
|
||||
context={'fiscalyear': fiscalyear,'state':self.datas['form']['state']})
|
||||
self.cr.execute("SELECT SUM(debit - credit) " \
|
||||
"FROM account_move_line AS line, account_account " \
|
||||
"WHERE (line.account_id = account_account.id) " \
|
||||
|
@ -163,7 +163,7 @@ class aged_trial_report(report_sxw.rml_parse):
|
|||
def _get_for_period(self, period, fiscalyear, company_id):
|
||||
account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line')
|
||||
line_query = account_move_line_obj._query_get(self.cr, self.uid, obj='line',
|
||||
context={'fiscalyear': fiscalyear})
|
||||
context={'fiscalyear': fiscalyear,'state':self.datas['form']['state']})
|
||||
self.cr.execute("SELECT SUM(debit - credit) " \
|
||||
"FROM account_move_line AS line, account_account " \
|
||||
"WHERE (line.account_id = account_account.id) " \
|
||||
|
|
|
@ -107,6 +107,7 @@ class general_ledger(report_sxw.rml_parse):
|
|||
ctx = self.context.copy()
|
||||
ctx['fiscalyear'] = form['fiscalyear']
|
||||
ctx['periods'] = form['periods'][0][2]
|
||||
ctx['state']=form['state']
|
||||
query = self.pool.get('account.move.line')._query_get(self.cr, self.uid, context=ctx)
|
||||
self.cr.execute("SELECT l.date, j.code, l.ref, l.name, l.debit, l.credit "\
|
||||
"FROM account_move_line l, account_journal j "\
|
||||
|
@ -126,6 +127,7 @@ class general_ledger(report_sxw.rml_parse):
|
|||
ctx = self.context.copy()
|
||||
ctx['fiscalyear'] = form['fiscalyear']
|
||||
ctx['periods'] = form['periods'][0][2]
|
||||
ctx['state']=form['state']
|
||||
query = self.pool.get('account.move.line')._query_get(self.cr, self.uid, context=ctx)
|
||||
self.cr.execute("SELECT sum(debit) "\
|
||||
"FROM account_move_line l "\
|
||||
|
@ -136,6 +138,7 @@ class general_ledger(report_sxw.rml_parse):
|
|||
ctx = self.context.copy()
|
||||
ctx['fiscalyear'] = form['fiscalyear']
|
||||
ctx['periods'] = form['periods'][0][2]
|
||||
ctx['state']=form['state']
|
||||
query = self.pool.get('account.move.line')._query_get(self.cr, self.uid, context=ctx)
|
||||
self.cr.execute("SELECT sum(credit) "\
|
||||
"FROM account_move_line l "\
|
||||
|
@ -148,6 +151,7 @@ class general_ledger(report_sxw.rml_parse):
|
|||
ctx = self.context.copy()
|
||||
ctx['fiscalyear'] = form['fiscalyear']
|
||||
ctx['periods'] = form['periods'][0][2]
|
||||
ctx['state']=form['state']
|
||||
query = self.pool.get('account.move.line')._query_get(self.cr, self.uid, context=ctx)
|
||||
self.cr.execute("SELECT sum(debit) "\
|
||||
"FROM account_move_line l "\
|
||||
|
@ -161,6 +165,7 @@ class general_ledger(report_sxw.rml_parse):
|
|||
ctx = self.context.copy()
|
||||
ctx['fiscalyear'] = form['fiscalyear']
|
||||
ctx['periods'] = form['periods'][0][2]
|
||||
ctx['state']=form['state']
|
||||
query = self.pool.get('account.move.line')._query_get(self.cr, self.uid, context=ctx)
|
||||
self.cr.execute("SELECT sum(credit) "\
|
||||
"FROM account_move_line l "\
|
||||
|
|
|
@ -82,7 +82,7 @@ class partner_balance(report_sxw.rml_parse):
|
|||
return []
|
||||
account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line')
|
||||
line_query = account_move_line_obj._query_get(self.cr, self.uid, obj='l',
|
||||
context={'fiscalyear': self.datas['form']['fiscalyear']})
|
||||
context={'fiscalyear': self.datas['form']['fiscalyear'],'state':self.datas['form']['state']})
|
||||
self.cr.execute(
|
||||
"SELECT p.ref, p.name, sum(debit) as debit, sum(credit) as credit, " \
|
||||
"CASE WHEN sum(debit) > sum(credit) " \
|
||||
|
@ -120,7 +120,7 @@ class partner_balance(report_sxw.rml_parse):
|
|||
account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line')
|
||||
line_query = account_move_line_obj._query_get(self.cr, self.uid,
|
||||
obj='account_move_line',
|
||||
context={'fiscalyear': self.datas['form']['fiscalyear']})
|
||||
context={'fiscalyear': self.datas['form']['fiscalyear'],'state':self.datas['form']['state']})
|
||||
self.cr.execute(
|
||||
'SELECT sum(debit) ' \
|
||||
'FROM account_move_line ' \
|
||||
|
@ -138,7 +138,7 @@ class partner_balance(report_sxw.rml_parse):
|
|||
account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line')
|
||||
line_query = account_move_line_obj._query_get(self.cr, self.uid,
|
||||
obj='account_move_line',
|
||||
context={'fiscalyear': self.datas['form']['fiscalyear']})
|
||||
context={'fiscalyear': self.datas['form']['fiscalyear'],'state':self.datas['form']['state']})
|
||||
self.cr.execute(
|
||||
'SELECT sum(credit) ' \
|
||||
'FROM account_move_line ' \
|
||||
|
@ -156,7 +156,7 @@ class partner_balance(report_sxw.rml_parse):
|
|||
account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line')
|
||||
line_query = account_move_line_obj._query_get(self.cr, self.uid,
|
||||
obj='account_move_line',
|
||||
context={'fiscalyear': self.datas['form']['fiscalyear']})
|
||||
context={'fiscalyear': self.datas['form']['fiscalyear'],'state':self.datas['form']['state']})
|
||||
self.cr.execute(
|
||||
'SELECT sum(debit-credit) ' \
|
||||
'FROM account_move_line ' \
|
||||
|
@ -175,7 +175,7 @@ class partner_balance(report_sxw.rml_parse):
|
|||
account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line')
|
||||
line_query = account_move_line_obj._query_get(self.cr, self.uid,
|
||||
obj='account_move_line',
|
||||
context={'fiscalyear': self.datas['form']['fiscalyear']})
|
||||
context={'fiscalyear': self.datas['form']['fiscalyear'],'state':self.datas['form']['state']})
|
||||
self.cr.execute(
|
||||
'SELECT CASE WHEN sum(debit) > sum(credit) ' \
|
||||
'THEN sum(debit - credit) ' \
|
||||
|
@ -197,7 +197,7 @@ class partner_balance(report_sxw.rml_parse):
|
|||
account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line')
|
||||
line_query = account_move_line_obj._query_get(self.cr, self.uid,
|
||||
obj='account_move_line',
|
||||
context={'fiscalyear': self.datas['form']['fiscalyear']})
|
||||
context={'fiscalyear': self.datas['form']['fiscalyear'],'state':self.datas['form']['state']})
|
||||
self.cr.execute(
|
||||
'SELECT CASE WHEN sum(debit) < sum(credit) ' \
|
||||
'THEN sum(credit - debit) ' \
|
||||
|
|
|
@ -49,7 +49,7 @@ class third_party_ledger(report_sxw.rml_parse):
|
|||
def preprocess(self, objects, data, ids):
|
||||
account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line')
|
||||
line_query = account_move_line_obj._query_get(self.cr, self.uid, obj='line',
|
||||
context={'fiscalyear': data['form']['fiscalyear']})
|
||||
context={'fiscalyear': data['form']['fiscalyear'],'state':data['form']['state']})
|
||||
self.cr.execute(
|
||||
"SELECT DISTINCT line.partner_id " \
|
||||
"FROM account_move_line AS line, account_account AS account " \
|
||||
|
@ -79,7 +79,7 @@ class third_party_ledger(report_sxw.rml_parse):
|
|||
def lines(self, partner):
|
||||
account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line')
|
||||
line_query = account_move_line_obj._query_get(self.cr, self.uid, obj='l',
|
||||
context={'fiscalyear': self.datas['form']['fiscalyear']})
|
||||
context={'fiscalyear': self.datas['form']['fiscalyear'],'state':self.datas['form']['state']})
|
||||
self.cr.execute(
|
||||
"SELECT l.date, j.code, l.ref, l.name, l.debit, l.credit " \
|
||||
"FROM account_move_line l " \
|
||||
|
@ -103,7 +103,7 @@ class third_party_ledger(report_sxw.rml_parse):
|
|||
account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line')
|
||||
line_query = account_move_line_obj._query_get(self.cr, self.uid,
|
||||
obj='account_move_line',
|
||||
context={'fiscalyear': self.datas['form']['fiscalyear']})
|
||||
context={'fiscalyear': self.datas['form']['fiscalyear'],'state':self.datas['form']['state']})
|
||||
self.cr.execute(
|
||||
"SELECT sum(debit) " \
|
||||
"FROM account_move_line " \
|
||||
|
@ -119,7 +119,7 @@ class third_party_ledger(report_sxw.rml_parse):
|
|||
account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line')
|
||||
line_query = account_move_line_obj._query_get(self.cr, self.uid,
|
||||
obj='account_move_line',
|
||||
context={'fiscalyear': self.datas['form']['fiscalyear']})
|
||||
context={'fiscalyear': self.datas['form']['fiscalyear'],'state':self.datas['form']['state']})
|
||||
self.cr.execute(
|
||||
"SELECT sum(credit) " \
|
||||
"FROM account_move_line " \
|
||||
|
@ -137,7 +137,7 @@ class third_party_ledger(report_sxw.rml_parse):
|
|||
account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line')
|
||||
line_query = account_move_line_obj._query_get(self.cr, self.uid,
|
||||
obj='account_move_line',
|
||||
context={'fiscalyear': self.datas['form']['fiscalyear']})
|
||||
context={'fiscalyear': self.datas['form']['fiscalyear'],'state':self.datas['form']['state']})
|
||||
self.cr.execute(
|
||||
"SELECT sum(debit) " \
|
||||
"FROM account_move_line " \
|
||||
|
@ -155,7 +155,7 @@ class third_party_ledger(report_sxw.rml_parse):
|
|||
account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line')
|
||||
line_query = account_move_line_obj._query_get(self.cr, self.uid,
|
||||
obj='account_move_line',
|
||||
context={'fiscalyear': self.datas['form']['fiscalyear']})
|
||||
context={'fiscalyear': self.datas['form']['fiscalyear'],'state':self.datas['form']['state']})
|
||||
self.cr.execute(
|
||||
"SELECT sum(credit) " \
|
||||
"FROM account_move_line " \
|
||||
|
|
|
@ -35,12 +35,14 @@ dates_form = '''<?xml version="1.0"?>
|
|||
<form string="Select period">
|
||||
<field name="fiscalyear" colspan="4"/>
|
||||
<field name="periods" colspan="4"/>
|
||||
<field name="state" colspan="4"/>
|
||||
</form>'''
|
||||
|
||||
dates_fields = {
|
||||
'fiscalyear': {'string': 'Fiscal year', 'type': 'many2one', 'relation': 'account.fiscalyear',
|
||||
'help': 'Keep empty for all open fiscal year'},
|
||||
'periods': {'string': 'Periods', 'type': 'many2many', 'relation': 'account.period', 'help': 'All periods if empty'}
|
||||
'periods': {'string': 'Periods', 'type': 'many2many', 'relation': 'account.period', 'help': 'All periods if empty'},
|
||||
'state':{'string':'State','type':'selection','selection': [('draft','Draft'), ('posted','Posted'),('all','All')],}
|
||||
}
|
||||
|
||||
class wizard_report(wizard.interface):
|
||||
|
@ -48,6 +50,7 @@ class wizard_report(wizard.interface):
|
|||
fiscalyear_obj = pooler.get_pool(cr.dbname).get('account.fiscalyear')
|
||||
data['form']['fiscalyear'] = fiscalyear_obj.find(cr, uid)
|
||||
data['form']['target_move'] = False
|
||||
data['form']['state']='all'
|
||||
if context.has_key('target_move'):
|
||||
data['form']['target_move'] = context['target_move']
|
||||
return data['form']
|
||||
|
|
|
@ -47,6 +47,8 @@ _aged_trial_form = """<?xml version="1.0"?>
|
|||
<field name="sorting_on"/>
|
||||
<newline/>
|
||||
<field name="computation"/>
|
||||
<newline/>
|
||||
<field name="state"/>
|
||||
</form>"""
|
||||
|
||||
_aged_trial_fields = {
|
||||
|
@ -55,7 +57,8 @@ _aged_trial_fields = {
|
|||
'help': 'Keep empty for all open fiscal year'},
|
||||
'period_length': {'string': 'Period length (days)', 'type': 'integer', 'required': True, 'default': lambda *a:30},
|
||||
'sorting_on':{'string': 'Sorting On', 'type': 'selection', 'selection': [('partner','By Partner Name (asc)'), ('amount','By Amount (desc)')],'required': True, 'default': lambda *a:'partner'},
|
||||
'computation':{'string': 'Computational Method', 'type': 'selection', 'selection': [("\'receivable\'",'On Receivables Only'), ("\'payable\'",'On Payables Only'), ("\'receivable\',\'payable\'",'On Receivables & Payables')], 'required': True, 'default': lambda *a:"\'receivable\'"}
|
||||
'computation':{'string': 'Computational Method', 'type': 'selection', 'selection': [("\'receivable\'",'On Receivables Only'), ("\'payable\'",'On Payables Only'), ("\'receivable\',\'payable\'",'On Receivables & Payables')], 'required': True, 'default': lambda *a:"\'receivable\'"},
|
||||
'state':{'string':'State','type':'selection','selection': [('draft','Draft'), ('posted','Posted'),('all','All')],}
|
||||
}
|
||||
|
||||
def _calc_dates(self, cr, uid, data, context):
|
||||
|
@ -85,7 +88,7 @@ class wizard_report(wizard.interface):
|
|||
else:
|
||||
company_id = pooler.get_pool(cr.dbname).get('res.company').search(cr, uid, [('parent_id', '=', False)])[0]
|
||||
data['form']['company_id'] = company_id
|
||||
|
||||
data['form']['state']='all'
|
||||
return data['form']
|
||||
|
||||
|
||||
|
|
|
@ -35,18 +35,21 @@ dates_form = '''<?xml version="1.0"?>
|
|||
<form string="Select period">
|
||||
<field name="fiscalyear" colspan="4"/>
|
||||
<field name="periods" colspan="4"/>
|
||||
<field name="state" colspan="4"/>
|
||||
</form>'''
|
||||
|
||||
dates_fields = {
|
||||
'fiscalyear': {'string': 'Fiscal year', 'type': 'many2one', 'relation': 'account.fiscalyear',
|
||||
'help': 'Keep empty for all open fiscal year'},
|
||||
'periods': {'string': 'Periods', 'type': 'many2many', 'relation': 'account.period', 'help': 'All periods if empty'}
|
||||
'periods': {'string': 'Periods', 'type': 'many2many', 'relation': 'account.period', 'help': 'All periods if empty'},
|
||||
'state':{'string':'State','type':'selection','selection': [('draft','Draft'), ('posted','Posted'),('all','All')],}
|
||||
}
|
||||
|
||||
class wizard_report(wizard.interface):
|
||||
def _get_defaults(self, cr, uid, data, context):
|
||||
fiscalyear_obj = pooler.get_pool(cr.dbname).get('account.fiscalyear')
|
||||
data['form']['fiscalyear'] = fiscalyear_obj.find(cr, uid)
|
||||
data['form']['state']='all'
|
||||
return data['form']
|
||||
|
||||
states = {
|
||||
|
|
|
@ -36,10 +36,12 @@ dates_form = '''<?xml version="1.0"?>
|
|||
<form string="Select period">
|
||||
<field name="company_id" colspan="4"/>
|
||||
<newline/>
|
||||
<field name="fiscalyear" colspan="4"/>
|
||||
<field name="fiscalyear" colspan="4"/>
|
||||
<newline/>
|
||||
<field name="date1"/>
|
||||
<field name="date2"/>
|
||||
<newline/>
|
||||
<field name="state" colspan="4"/>
|
||||
</form>'''
|
||||
|
||||
dates_fields = {
|
||||
|
@ -48,6 +50,7 @@ dates_fields = {
|
|||
'help': 'Keep empty for all open fiscal year'},
|
||||
'date1': {'string':'Start of period', 'type':'date', 'required':True, 'default': lambda *a: time.strftime('%Y-01-01')},
|
||||
'date2': {'string':'End of period', 'type':'date', 'required':True, 'default': lambda *a: time.strftime('%Y-%m-%d')},
|
||||
'state':{'string':'State','type':'selection','selection': [('draft','Draft'), ('posted','Posted'),('all','All')],}
|
||||
}
|
||||
|
||||
class wizard_report(wizard.interface):
|
||||
|
@ -61,6 +64,7 @@ class wizard_report(wizard.interface):
|
|||
else:
|
||||
company_id = pooler.get_pool(cr.dbname).get('res.company').search(cr, uid, [('parent_id', '=', False)])[0]
|
||||
data['form']['company_id'] = company_id
|
||||
data['form']['state']='all'
|
||||
|
||||
return data['form']
|
||||
|
||||
|
|
|
@ -39,6 +39,8 @@ dates_form = '''<?xml version="1.0"?>
|
|||
<newline/>
|
||||
<field name="date1"/>
|
||||
<field name="date2"/>
|
||||
<newline/>
|
||||
<field name="state" colspan="4"/>
|
||||
</form>'''
|
||||
|
||||
dates_fields = {
|
||||
|
@ -47,6 +49,7 @@ dates_fields = {
|
|||
'help': 'Keep empty for all open fiscal year'},
|
||||
'date1': {'string':'Start of period', 'type':'date', 'required':True, 'default': lambda *a: time.strftime('%Y-01-01')},
|
||||
'date2': {'string':'End of period', 'type':'date', 'required':True, 'default': lambda *a: time.strftime('%Y-%m-%d')},
|
||||
'state':{'string':'State','type':'selection','selection': [('draft','Draft'), ('posted','Posted'),('all','All')],}
|
||||
}
|
||||
|
||||
class wizard_report(wizard.interface):
|
||||
|
@ -60,7 +63,7 @@ class wizard_report(wizard.interface):
|
|||
else:
|
||||
company_id = pooler.get_pool(cr.dbname).get('res.company').search(cr, uid, [('parent_id', '=', False)])[0]
|
||||
data['form']['company_id'] = company_id
|
||||
|
||||
data['form']['state']='all'
|
||||
return data['form']
|
||||
|
||||
states = {
|
||||
|
|
|
@ -414,6 +414,16 @@ class product_product(osv.osv):
|
|||
'price_margin': fields.float('Price Margin', digits=(16, int(config['price_accuracy']))),
|
||||
}
|
||||
|
||||
def onchange_uom(self, cursor, user, ids, uom_id,uom_po_id):
|
||||
if uom_id and uom_po_id:
|
||||
uom_obj=self.pool.get('product.uom')
|
||||
uom=uom_obj.browse(cursor,user,[uom_id])[0]
|
||||
uom_po=uom_obj.browse(cursor,user,[uom_po_id])[0]
|
||||
print uom.category_id.id , uom_po.category_id.id
|
||||
if uom.category_id.id != uom_po.category_id.id:
|
||||
return {'value': {'uom_po_id': uom_id}}
|
||||
return False
|
||||
|
||||
def _check_ean_key(self, cr, uid, ids):
|
||||
for partner in self.browse(cr, uid, ids):
|
||||
if not partner.ean13:
|
||||
|
|
|
@ -46,7 +46,7 @@
|
|||
<field digits="(14, 3)" groups="base.group_extended" name="weight_net" attrs="{'readonly':[('type','=','service')]}"/>
|
||||
<field name="procure_method"/>
|
||||
<field name="state" select="2"/>
|
||||
<field name="uom_id"/>
|
||||
<field name="uom_id" on_change="onchange_uom(uom_id,uom_po_id)"/>
|
||||
<field name="uom_po_id"/>
|
||||
<field groups="base.group_extended" name="product_manager" select="2"/>
|
||||
</page>
|
||||
|
|
|
@ -1185,5 +1185,61 @@ class product_product(osv.osv):
|
|||
}
|
||||
product_product()
|
||||
|
||||
# Move wizard :
|
||||
# get confirm or assign stock move lines of partner and put in current picking.
|
||||
class stock_picking_move_wizard(osv.osv_memory):
|
||||
_name='stock.picking.move.wizard'
|
||||
def _get_picking(self,cr, uid, ctx):
|
||||
if 'action_id' in ctx:
|
||||
return ctx['action_id']
|
||||
return False
|
||||
def _get_move_lines(self,cr,uid,ctx):
|
||||
move_obj=self.pool.get('stock.move')
|
||||
picking_obj=self.pool.get('stock.picking')
|
||||
if 'action_id' in ctx:
|
||||
picking=picking_obj.browse(cr,uid,[ctx['action_id']])
|
||||
if picking and len(picking):
|
||||
move_line_ids=move_obj.search(cr,uid,[('state','in',['confirmed','assigned']),('address_id','=',picking[0].address_id.id)])
|
||||
move_lines=move_obj.read(cr,uid,move_line_ids)
|
||||
#res=[]
|
||||
#for move_line in move_lines:
|
||||
# res.append((0,0,move_line))
|
||||
return [{'move_ids':(0,0,move_lines)}]
|
||||
return []
|
||||
def _get_picking_address(self,cr,uid,ctx):
|
||||
picking_obj=self.pool.get('stock.picking')
|
||||
if 'action_id' in ctx:
|
||||
picking=picking_obj.browse(cr,uid,[ctx['action_id']])[0]
|
||||
return picking.address_id and picking.address_id.id
|
||||
return False
|
||||
|
||||
|
||||
_columns={
|
||||
'name':fields.char('Name',size=64,invisible=True),
|
||||
#'move_lines': fields.one2many('stock.move', 'picking_id', 'Move lines',readonly=True),
|
||||
'move_ids': fields.many2many('stock.move', 'picking_move_wizard_rel', 'picking_move_wizard_id', 'move_id', 'Move lines'),
|
||||
'address_id' : fields.many2one('res.partner.address', 'Dest. Address',invisible=True),
|
||||
'picking_id': fields.many2one('stock.picking', 'Packing list', select=True,invisible=True),
|
||||
}
|
||||
_defaults={
|
||||
'picking_id':_get_picking,
|
||||
'address_id':_get_picking_address,
|
||||
}
|
||||
def action_move(self,cr,uid,ids,context=None):
|
||||
move_obj=self.pool.get('stock.move')
|
||||
picking_obj=self.pool.get('stock.picking')
|
||||
for act in self.read(cr,uid,ids):
|
||||
move_lines=move_obj.browse(cr,uid,act['move_ids'])
|
||||
for line in move_lines:
|
||||
picking_obj.write(cr,uid,[line.picking_id.id],{'move_lines':[(1,line.id,{'picking_id':act['picking_id']})]})
|
||||
picking_obj.write(cr,uid,[act['picking_id']],{'move_lines':[(1,line.id,{'picking_id':act['picking_id']})]})
|
||||
cr.commit()
|
||||
old_picking=picking_obj.read(cr,uid,[line.picking_id.id])[0]
|
||||
if not len(old_picking['move_lines']):
|
||||
picking_obj.write(cr,uid,[old_picking['id']],{'state':'done'})
|
||||
return {'type':'ir.actions.act_window_close' }
|
||||
|
||||
stock_picking_move_wizard()
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
|
|
|
@ -1185,6 +1185,31 @@
|
|||
<field eval="'ir.actions.act_window,%d'%act_product_location_open" name="value"/>
|
||||
<field eval="True" name="object"/>
|
||||
</record>
|
||||
|
||||
<record id="stock_picking_move_wizard_form" model="ir.ui.view">
|
||||
<field name="name">stock.picking.move.wizard.form</field>
|
||||
<field name="model">stock.picking.move.wizard</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Move Lines">
|
||||
<field name="address_id" invisible="True"/>
|
||||
<field name="picking_id" invisible="True"/>
|
||||
<field domain="[('picking_id','<>',picking_id),('address_id','=',address_id),('state','in',['confirmed','assigned'])]" name="move_ids" select="1"/><newline/>
|
||||
<group colspan="4">
|
||||
<button special="cancel" string="Cancel"/>
|
||||
<button name="action_move" string="Add" type="object"/>
|
||||
</group>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<act_window name="Get move lines"
|
||||
context="{'action_id': active_id}"
|
||||
res_model="stock.picking.move.wizard"
|
||||
src_model="stock.picking"
|
||||
view_mode="form"
|
||||
target="new"
|
||||
id="act_stock_picking_move_wizard"/>
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue