[IMP] Clean wizard code

[IMP] View and search on sequence
[IMP] Add copy method to allow dupplication
[IMP] Fix popup name when using button to create picking from claim and picking
[FIX] PEP8 and various coding standards
This commit is contained in:
Joel Grand-Guillaume
2013-11-13 15:29:18 +01:00
parent 1d3dfc9f0b
commit 5fea9a408d
9 changed files with 211 additions and 80 deletions

View File

@@ -61,7 +61,19 @@ class claim_line(orm.Model):
res = {}
for line in self.browse(cr,uid,ids):
res[line.id] = line.unit_sale_price*line.product_returned_quantity
return res
return res
def copy_data(self, cr, uid, id, default=None, context=None):
if default is None:
default = {}
std_default = {
'move_in_id': False,
'move_out_id': False,
'refund_line_id': False,
}
std_default.update(default)
return super(claim_line, self).copy_data(
cr, uid, id, default=std_default, context=context)
_columns = {
'name': fields.char('Description', size=64,required=True),
@@ -261,10 +273,35 @@ class crm_claim(orm.Model):
_('There is no warehouse for the current user\'s company!'))
return wh_ids[0]
def name_get(self, cr, uid, ids, context=None):
res = []
for claim in self.browse(cr, uid, ids, context=context):
res.append((claim.id, '[' + claim.number + '] ' + claim.name))
return res
def create(self, cr, uid, vals, context=None):
if ('number' not in vals) or (vals.get('number')=='/'):
vals['number'] = self._get_sequence_number(cr, uid, context=context)
new_id = super(crm_claim, self).create(cr, uid, vals, context)
return new_id
def copy_data(self, cr, uid, id, default=None, context=None):
if default is None:
default = {}
std_default = {
'invoice_ids': False,
'picking_ids': False,
'number': self._get_sequence_number(cr, uid, context=context),
}
std_default.update(default)
return super(crm_claim, self).copy_data(
cr, uid, id, default=std_default, context=context)
_columns = {
'number': fields.char('Number', readonly=True,
states={'draft': [('readonly', False)]},
required=True,
select=True,
help="Company internal claim unique number"),
'claim_type': fields.selection([('customer','Customer'),
('supplier','Supplier'),
@@ -288,11 +325,15 @@ class crm_claim(orm.Model):
}
_defaults = {
'number': _get_sequence_number,
'number': lambda self, cr, uid, context: '/',
'claim_type': 'customer',
'warehouse_id': _get_default_warehouse,
}
_sql_constraints = [
('number_uniq', 'unique(number, company_id)', 'Number/Reference must be unique per Company!'),
]
def onchange_partner_address_id(self, cr, uid, ids, add,
email=False, context=None):
res = super(crm_claim, self).onchange_partner_address_id(cr, uid, ids,

View File

@@ -119,6 +119,9 @@
<field name="stage_id" position="after">
<field name="section_id" />
</field>
<field name="name" position="before">
<field name="number" />
</field>
</field>
</record>
@@ -199,20 +202,31 @@
<field name="inherit_id" ref="crm_claim.crm_case_claims_form_view"/>
<field name="arch" type="xml">
<field name="date_deadline" position="after">
<field name="number"/>
<field name="claim_type"/>
<field name="warehouse_id" />
</field>
<field name="name" position="replace">
<div class="oe_title">
<h1><field name="number" class="oe_inline"/> - <field name="name" class="oe_inline"/></h1>
</div>
</field>
<field name="date" position="replace">
</field>
<field name="user_id" position="before">
<field name="date" />
</field>
</field>
</record>
<!-- Crm claim Search view -->
<record id="view_crm_case_claims_filter" model="ir.ui.view">
<field name="name">CRM - Claims Search</field>
<field name="model">crm.claim</field>
<field name="inherit_id" ref="crm_claim.view_crm_case_claims_filter"/>
<field name="arch" type="xml">
<field name="name" string="Claims" position="before">
<field name="number"/>
</field>
<filter string="Stage" icon="terp-stage" domain="[]" context="{'group_by':'stage_id'}" position="before">
<filter string="Sales Team" icon="terp-stock_symbol-selection" domain="[]" context="{'group_by':'section_id'}"/>
</filter>

View File

@@ -78,7 +78,7 @@ class stock_warehouse(orm.Model):
#This part concern the case of a wrong picking out. We need to create a new
#stock_move in a micking already open.
#stock_move in a picking already open.
#In order to don't have to confirm the stock_move we override the create and
#confirm it at the creation only for this case
class stock_move(orm.Model):

View File

@@ -23,6 +23,7 @@ from openerp.osv import fields, orm
class account_invoice_refund(orm.TransientModel):
_inherit = "account.invoice.refund"
def compute_refund(self, cr, uid, ids, mode='refund', context=None):

View File

@@ -20,20 +20,31 @@
#You should have received a copy of the GNU General Public License #
#along with this program. If not, see <http://www.gnu.org/licenses/>. #
#########################################################################
from openerp.osv import fields, orm
from openerp.osv import fields, orm, osv
from openerp.tools import DEFAULT_SERVER_DATE_FORMAT, DEFAULT_SERVER_DATETIME_FORMAT
from openerp import netsvc
from openerp.tools.translate import _
import time
from tools import DEFAULT_SERVER_DATE_FORMAT, DEFAULT_SERVER_DATETIME_FORMAT
import netsvc
from tools.translate import _
class claim_make_picking(orm.TransientModel):
_name='claim_make_picking.wizard'
_description='Wizard to create pickings from claim lines'
_name = 'claim_make_picking.wizard'
_description = 'Wizard to create pickings from claim lines'
_columns = {
'claim_line_source_location' : fields.many2one('stock.location', 'Source Location',help="Location where the returned products are from.", required=True),
'claim_line_dest_location' : fields.many2one('stock.location', 'Dest. Location',help="Location where the system will stock the returned products.", required=True),
'claim_line_ids' : fields.many2many('claim.line', 'claim_line_picking', 'claim_picking_id', 'claim_line_id', 'Claim lines'),
'claim_line_source_location': fields.many2one('stock.location',
'Source Location',
help="Location where the returned products are from.",
required=True),
'claim_line_dest_location': fields.many2one('stock.location',
'Dest. Location',
help="Location where the system will stock the returned products.",
required=True),
'claim_line_ids': fields.many2many('claim.line',
'claim_line_picking',
'claim_picking_id',
'claim_line_id',
'Claim lines'),
}
def _get_claim_lines(self, cr, uid, context):
@@ -45,25 +56,33 @@ class claim_make_picking(orm.TransientModel):
elif context.get('picking_type') == 'out':
move_field = 'move_out_id'
good_lines = []
line_ids = line_obj.search(cr, uid, [('claim_id', '=', context['active_id'])], context=context)
line_ids = line_obj.search(cr, uid,
[('claim_id', '=', context['active_id'])], context=context)
for line in line_obj.browse(cr, uid, line_ids, context=context):
if not line[move_field] or line[move_field].state == 'cancel':
good_lines.append(line.id)
if not good_lines:
raise osv.except_osv(_('Error !'), _('A picking has already been created for this claim !'))
raise osv.except_osv(_('Error !'),
_('A picking has already been created for this claim !'))
return good_lines
# Get default source location
def _get_source_loc(self, cr, uid, context):
loc_id = False
if context is None: context = {}
warehouse_obj = self.pool.get('stock.warehouse')
warehouse_id = context.get('warehouse_id')
if context.get('picking_type') == 'out':
loc_id = warehouse_obj.read(cr, uid, warehouse_id, ['lot_stock_id'], context=context)['lot_stock_id'][0]
elif context.get('picking_type') in ['in', 'loss'] and context.get('partner_id'):
loc_id = self.pool.get('res.partner').read(cr, uid, context['partner_id'],
['property_stock_customer'],
context=context)['property_stock_customer']
loc_id = warehouse_obj.read(cr, uid,
warehouse_id,
['lot_stock_id'],
context=context)['lot_stock_id'][0]
elif (context.get('picking_type') in ['in', 'loss']
and context.get('partner_id')):
loc_id = self.pool.get('res.partner').read(cr, uid,
context['partner_id'],
['property_stock_customer'],
context=context)['property_stock_customer']
return loc_id
# Get default destination location
@@ -72,11 +91,20 @@ class claim_make_picking(orm.TransientModel):
warehouse_obj = self.pool.get('stock.warehouse')
warehouse_id = context.get('warehouse_id')
if context.get('picking_type') == 'out':
loc_id = self.pool.get('res.partner').read(cr, uid, context.get('partner_id'), ['property_stock_customer'], context=context)['property_stock_customer'][0]
loc_id = self.pool.get('res.partner').read(cr, uid,
context.get('partner_id'),
['property_stock_customer'],
context=context)['property_stock_customer'][0]
elif context.get('picking_type') == 'in':
loc_id = warehouse_obj.read(cr, uid, warehouse_id, ['lot_rma_id'], context=context)['lot_rma_id'][0]
loc_id = warehouse_obj.read(cr, uid,
warehouse_id,
['lot_rma_id'],
context=context)['lot_rma_id'][0]
elif context.get('picking_type') == 'loss':
loc_id = warehouse_obj.read(cr, uid, warehouse_id, ['lot_carrier_loss_id'], context=context)['lot_carrier_loss_id'][0]
loc_id = warehouse_obj.read(cr, uid,
warehouse_id,
['lot_carrier_loss_id'],
context=context)['lot_carrier_loss_id'][0]
return loc_id
_defaults = {
@@ -118,7 +146,8 @@ class claim_make_picking(orm.TransientModel):
('name', '=', view_name)
], context=context)[0]
wizard = self.browse(cr, uid, ids[0], context=context)
claim = self.pool.get('crm.claim').browse(cr, uid, context['active_id'], context=context)
claim = self.pool.get('crm.claim').browse(cr, uid,
context['active_id'], context=context)
partner_id = claim.partner_id.id
# create picking
picking_id = picking_obj.create(cr, uid, {
@@ -158,17 +187,20 @@ class claim_make_picking(orm.TransientModel):
'location_dest_id': wizard.claim_line_dest_location.id,
'note': note,
})
self.pool.get('claim.line').write(cr, uid, wizard_claim_line.id, {write_field: move_id}, context=context)
self.pool.get('claim.line').write(cr, uid,
wizard_claim_line.id, {write_field: move_id}, context=context)
wf_service = netsvc.LocalService("workflow")
if picking_id:
wf_service.trg_validate(uid, 'stock.picking', picking_id,'button_confirm', cr)
wf_service.trg_validate(uid, 'stock.picking',
picking_id,'button_confirm', cr)
picking_obj.action_assign(cr, uid, [picking_id])
domain = "[('type','=','%s'),('partner_id','=',%s)]"%(p_type, partner_id)
return {
'name': '%s' % name,
'view_type': 'form',
'view_mode': 'form',
'view_id': view_id,
'domain' : "[('type', '=', '%s'),('partner_id','=',%s)]" % (p_type, partner_id),
'domain' : domain,
'res_model': 'stock.picking',
'res_id': picking_id,
'type': 'ir.actions.act_window',

View File

@@ -20,41 +20,55 @@
#You should have received a copy of the GNU General Public License #
#along with this program. If not, see <http://www.gnu.org/licenses/>. #
#########################################################################
from openerp.osv import fields, orm
from openerp.tools import DEFAULT_SERVER_DATE_FORMAT, DEFAULT_SERVER_DATETIME_FORMAT
from openerp import netsvc
import time
from tools import DEFAULT_SERVER_DATE_FORMAT, DEFAULT_SERVER_DATETIME_FORMAT
import netsvc
class claim_make_picking_from_picking(orm.TransientModel):
_name='claim_make_picking_from_picking.wizard'
_description='Wizard to create pickings from picking lines'
_name = 'claim_make_picking_from_picking.wizard'
_description = 'Wizard to create pickings from picking lines'
_columns = {
'picking_line_source_location' : fields.many2one('stock.location', 'Source Location',help="Location where the returned products are from.", required=True),
'picking_line_dest_location' : fields.many2one('stock.location', 'Dest. Location',help="Location where the system will stock the returned products.", required=True),
'picking_line_ids' : fields.many2many('stock.move', 'claim_picking_line_picking', 'claim_picking_id', 'picking_line_id', 'Picking lines'),
'picking_line_source_location': fields.many2one('stock.location',
'Source Location',
help="Location where the returned products are from.",
required=True),
'picking_line_dest_location': fields.many2one('stock.location',
'Dest. Location',
help="Location where the system will stock the returned products.",
required=True),
'picking_line_ids': fields.many2many('stock.move',
'claim_picking_line_picking',
'claim_picking_id',
'picking_line_id',
'Picking lines'),
}
def _get_picking_lines(self, cr, uid, context):
return self.pool.get('stock.picking').read(cr, uid, context['active_id'], ['move_lines'], context=context)['move_lines']
return self.pool.get('stock.picking').read(cr, uid,
context['active_id'], ['move_lines'], context=context)['move_lines']
# Get default source location
def _get_source_loc(self, cr, uid, context):
if context is None: context = {}
warehouse_obj = self.pool.get('stock.warehouse')
warehouse_id = context.get('warehouse_id')
return warehouse_obj.read(cr, uid, warehouse_id, ['lot_rma_id'], context=context)['lot_rma_id'][0]
return warehouse_obj.read(cr, uid,
warehouse_id, ['lot_rma_id'], context=context)['lot_rma_id'][0]
# Get default destination location
def _get_dest_loc(self, cr, uid, context):
if context is None: context = {}
warehouse_obj = self.pool.get('stock.warehouse')
warehouse_id = context.get('warehouse_id')
print warehouse_id
if context.get('picking_type'):
context_loc = context.get('picking_type')[8:]
loc_field = 'lot_%s_id' %context.get('picking_type')[8:]
loc_id = warehouse_obj.read(cr, uid, warehouse_id, [loc_field], context=context)[loc_field][0]
loc_id = warehouse_obj.read(cr, uid,
[warehouse_id], [loc_field], context=context)[loc_field][0]
return loc_id
_defaults = {
@@ -84,7 +98,8 @@ class claim_make_picking_from_picking(orm.TransientModel):
('name', '=', 'stock.picking.form')
], context=context)[0]
wizard = self.browse(cr, uid, ids[0], context=context)
prev_picking = picking_obj.browse(cr, uid, context['active_id'], context=context)
prev_picking = picking_obj.browse(cr, uid,
context['active_id'], context=context)
partner_id = prev_picking.partner_id.id
# create picking
picking_id = picking_obj.create(cr, uid, {
@@ -124,17 +139,22 @@ class claim_make_picking_from_picking(orm.TransientModel):
'location_dest_id': wizard.picking_line_dest_location.id,
'note': note,
})
wizard_move = move_obj.write(cr, uid, wizard_picking_line.id, {'move_dest_id': move_id}, context=context)
wizard_move = move_obj.write(cr, uid,
wizard_picking_line.id,
{'move_dest_id': move_id},
context=context)
wf_service = netsvc.LocalService("workflow")
if picking_id:
wf_service.trg_validate(uid, 'stock.picking', picking_id,'button_confirm', cr)
wf_service.trg_validate(uid,
'stock.picking', picking_id,'button_confirm', cr)
picking_obj.action_assign(cr, uid, [picking_id])
domain = "[('type','=','%s'),('partner_id','=',%s)]"%(p_type, partner_id)
return {
'name': '%s' % name,
'view_type': 'form',
'view_mode': 'form',
'view_id': view_id,
'domain' : "[('type', '=', '%s'),('partner_id','=',%s)]" % (p_type, partner_id),
'domain' : domain,
'res_model': 'stock.picking',
'res_id': picking_id,
'type': 'ir.actions.act_window',

View File

@@ -27,7 +27,7 @@
</record>
<record id="action_stock_picking_from_claim_picking" model="ir.actions.act_window">
<field name="name">action_stock_picking_from_claim_picking</field>
<field name="name">Create Incomming Shipment to Stock</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">claim_make_picking_from_picking.wizard</field>
<field name="src_model">stock.picking</field>
@@ -38,7 +38,7 @@
</record>
<record id="action_loss_picking_from_claim_picking" model="ir.actions.act_window">
<field name="name">action_loss_picking_from_claim_picking</field>
<field name="name">Create Incomming Shipment to Breakkage Loss Location</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">claim_make_picking_from_picking.wizard</field>
<field name="src_model">stock.picking</field>
@@ -49,7 +49,7 @@
</record>
<record id="action_used_picking_from_claim_picking" model="ir.actions.act_window">
<field name="name">action_used_picking_from_claim_picking</field>
<field name="name">Create Incomming Shipment to Refurbish Location</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">claim_make_picking_from_picking.wizard</field>
<field name="src_model">stock.picking</field>

View File

@@ -27,7 +27,7 @@
</record>
<record id="action_claim_picking_in" model="ir.actions.act_window">
<field name="name">action_claim_picking_in</field>
<field name="name">Create Incoming Shipments</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">claim_make_picking.wizard</field>
<field name="src_model">crm.claim</field>
@@ -38,7 +38,7 @@
</record>
<record id="action_claim_picking_out" model="ir.actions.act_window">
<field name="name">action_claim_picking_out</field>
<field name="name">Create Outgoing Shipments</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">claim_make_picking.wizard</field>
<field name="src_model">crm.claim</field>
@@ -49,7 +49,7 @@
</record>
<record id="action_claim_picking_loss" model="ir.actions.act_window">
<field name="name">action_claim_picking_loss</field>
<field name="name">Create Products Loss</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">claim_make_picking.wizard</field>
<field name="src_model">crm.claim</field>

View File

@@ -20,18 +20,23 @@
#along with this program. If not, see <http://www.gnu.org/licenses/>. #
#########################################################################
from openerp.osv import fields, orm
import pooler
class returned_lines_from_serial(orm.TransientModel):
_name='returned_lines_from_serial.wizard'
_description='Wizard to create product return lines from serial numbers'
_name = 'returned_lines_from_serial.wizard'
_description = 'Wizard to create product return lines from serial numbers'
_columns = {
'prodlot_id_1': fields.many2one('stock.production.lot', 'Serial / Lot Number 1', required=True),
'prodlot_id_2': fields.many2one('stock.production.lot', 'Serial / Lot Number 2'),
'prodlot_id_3': fields.many2one('stock.production.lot', 'Serial / Lot Number 3'),
'prodlot_id_4': fields.many2one('stock.production.lot', 'Serial / Lot Number 4'),
'prodlot_id_5': fields.many2one('stock.production.lot', 'Serial / Lot Number 5'),
'prodlot_id_1': fields.many2one('stock.production.lot',
'Serial / Lot Number 1', required=True),
'prodlot_id_2': fields.many2one('stock.production.lot',
'Serial / Lot Number 2'),
'prodlot_id_3': fields.many2one('stock.production.lot',
'Serial / Lot Number 3'),
'prodlot_id_4': fields.many2one('stock.production.lot',
'Serial / Lot Number 4'),
'prodlot_id_5': fields.many2one('stock.production.lot',
'Serial / Lot Number 5'),
'qty_1' : fields.float('Quantity 1', digits=(12,2), required=True),
'qty_2' : fields.float('Quantity 2', digits=(12,2)),
'qty_3' : fields.float('Quantity 3', digits=(12,2)),
@@ -44,7 +49,9 @@ class returned_lines_from_serial(orm.TransientModel):
('error','Shipping error'),
('exchange','Exchange request'),
('lost','Lost during transport'),
('other','Other')], 'Claim Subject', required=True, help="To describe the product problem"),
('other','Other')], 'Claim Subject',
required=True,
help="To describe the product problem"),
'claim_2': fields.selection([('none','Not specified'),
('legal','Legal retractation'),
('cancellation','Order cancellation'),
@@ -52,7 +59,9 @@ class returned_lines_from_serial(orm.TransientModel):
('error','Shipping error'),
('exchange','Exchange request'),
('lost','Lost during transport'),
('other','Other')], 'Claim Subject', required=True, help="To describe the line product problem"),
('other','Other')], 'Claim Subject',
required=True,
help="To describe the line product problem"),
'claim_3': fields.selection([('none','Not specified'),
('legal','Legal retractation'),
('cancellation','Order cancellation'),
@@ -60,7 +69,9 @@ class returned_lines_from_serial(orm.TransientModel):
('error','Shipping error'),
('exchange','Exchange request'),
('lost','Lost during transport'),
('other','Other')], 'Claim Subject', required=True, help="To describe the line product problem"),
('other','Other')], 'Claim Subject',
required=True,
help="To describe the line product problem"),
'claim_4': fields.selection([('none','Not specified'),
('legal','Legal retractation'),
('cancellation','Order cancellation'),
@@ -68,7 +79,9 @@ class returned_lines_from_serial(orm.TransientModel):
('error','Shipping error'),
('exchange','Exchange request'),
('lost','Lost during transport'),
('other','Other')], 'Claim Subject', required=True, help="To describe the line product problem"),
('other','Other')], 'Claim Subject',
required=True,
help="To describe the line product problem"),
'claim_5': fields.selection([('none','Not specified'),
('legal','Legal retractation'),
('cancellation','Order cancellation'),
@@ -76,13 +89,16 @@ class returned_lines_from_serial(orm.TransientModel):
('error','Shipping error'),
('exchange','Exchange request'),
('lost','Lost during transport'),
('other','Other')], 'Claim Subject', required=True, help="To describe the line product problem"),
('other','Other')], 'Claim Subject',
required=True,
help="To describe the line product problem"),
'partner_id': fields.many2one('res.partner', 'Partner'),
}
# Get partner from case is set to filter serials
def _get_default_partner_id(self, cr, uid, context):
return self.pool.get('crm.claim').read(cr, uid, context['active_id'], ['partner_id'])['partner_id'][0]
return self.pool.get('crm.claim').read(cr, uid,
context['active_id'], ['partner_id'])['partner_id'][0]
_defaults = {
'qty_1': lambda *a: 1.0,
@@ -135,7 +151,8 @@ class returned_lines_from_serial(orm.TransientModel):
return_line.create(cr, uid, {
'claim_id': context['active_id'],
'claim_origine': result.claim_1,
'product_id' : self.get_product_id(cr, uid,ids,result.prodlot_id_1.id,context),
'product_id' : self.get_product_id(cr, uid, ids,
result.prodlot_id_1.id, context=context),
#'invoice_id' : self.prodlot_2_invoice(cr, uid,[result.prodlot_id_1.id],[result.prodlot_id_1.product_id.id]), #PRODLOT_ID can be in many invoice !!
'product_returned_quantity' : result.qty_1,
'prodlot_id' : result.prodlot_id_1.id,
@@ -148,7 +165,8 @@ class returned_lines_from_serial(orm.TransientModel):
return_line.create(cr, uid, {
'claim_id': context['active_id'],
'claim_origine': result.claim_2,
'product_id' : self.get_product_id(cr, uid,ids,result.prodlot_id_2.id,context),
'product_id' : self.get_product_id(cr, uid, ids,
result.prodlot_id_2.id, context=context),
# 'invoice_id' : self.prodlot_2_invoice(cr, uid,[result.prodlot_id_1.id]),
'product_returned_quantity' : result.qty_2,
'prodlot_id' : result.prodlot_id_2.id,
@@ -161,7 +179,8 @@ class returned_lines_from_serial(orm.TransientModel):
return_line.create(cr, uid, {
'claim_id': context['active_id'],
'claim_origine': result.claim_3,
'product_id' : self.get_product_id(cr, uid,ids,result.prodlot_id_3.id,context),
'product_id' : self.get_product_id(cr, uid, ids,
result.prodlot_id_3.id, context=context),
# 'invoice_id' : self.prodlot_2_invoice(cr, uid,[result.prodlot_id_1.id]),
'product_returned_quantity' : result.qty_3,
'prodlot_id' : result.prodlot_id_3.id,
@@ -174,7 +193,8 @@ class returned_lines_from_serial(orm.TransientModel):
return_line.create(cr, uid, {
'claim_id': context['active_id'],
'claim_origine': result.claim_4,
'product_id' : self.get_product_id(cr, uid,ids,result.prodlot_id_4.id,context),
'product_id' : self.get_product_id(cr, uid, ids,
result.prodlot_id_4.id, context=context),
# 'invoice_id' : self.prodlot_2_invoice(cr, uid,[result.prodlot_id_1.id]),
'product_returned_quantity' : result.qty_4,
'prodlot_id' : result.prodlot_id_4.id,
@@ -187,7 +207,8 @@ class returned_lines_from_serial(orm.TransientModel):
return_line.create(cr, uid, {
'claim_id': context['active_id'],
'claim_origine': result.claim_5,
'product_id' : self.get_product_id(cr, uid,ids,result.prodlot_id_5.id,context),
'product_id' : self.get_product_id(cr, uid, ids,
result.prodlot_id_5.id, context=context),
# 'invoice_id' : self.prodlot_2_invoice(cr, uid,[result.prodlot_id_1.id],[result.prodlot_id_1.product_id.id]),
'product_returned_quantity' : result.qty_5,
'prodlot_id' : result.prodlot_id_5.id,
@@ -201,16 +222,16 @@ class returned_lines_from_serial(orm.TransientModel):
return True
def prodlot_2_product(self,cr, uid, prodlot_ids):
stock_move_ids=self.pool.get('stock.move').search(cr, uid, [('prodlot_id', 'in', prodlot_ids)])
res=self.pool.get('stock.move').read(cr, uid, stock_move_ids, ['product_id'])
stock_move_ids = self.pool.get('stock.move').search(cr, uid,
[('prodlot_id', 'in', prodlot_ids)])
res = self.pool.get('stock.move').read(cr, uid,
stock_move_ids, ['product_id'])
return set([x['product_id'][0] for x in res if x['product_id']])
def prodlot_2_invoice(self,cr, uid, prodlot_id,product_id):
print "prodlot_ids : ", prodlot_id
print "product_id : ", product_id
# get stock_move_ids
stock_move_ids = self.pool.get('stock.move').search(cr, uid, [('prodlot_id', 'in', prodlot_id)])
print "stock_move_ids : ", stock_move_ids
stock_move_ids = self.pool.get('stock.move').search(cr, uid,
[('prodlot_id', 'in', prodlot_id)])
# if 1 id
# (get stock picking (filter on out ?))
# get invoice_ids from stock_move_id where invoice.line.product = prodlot_product and invoice customer = claim_partner
@@ -226,19 +247,21 @@ class returned_lines_from_serial(orm.TransientModel):
def stock_move_2_invoice(self, cr, uid, stock_move_ids):
inv_line_ids = []
res=self.pool.get('stock.move').read(cr, uid, stock_move_ids, ['sale_line_id'])
res = self.pool.get('stock.move').read(cr, uid,
stock_move_ids, ['sale_line_id'])
sale_line_ids = [x['sale_line_id'][0] for x in res if x['sale_line_id']]
if not sale_line_ids:
return []
cr.execute("select invoice_id from sale_order_line_invoice_rel where order_line_id in ("+ ','.join(map(lambda x: str(x),sale_line_ids))+')')
sql_base = "select invoice_id from sale_order_line_invoice_rel where \
order_line_id in ("
cr.execute(sql_base + ','.join(map(lambda x: str(x),sale_line_ids))+')')
res = cr.fetchall()
for i in res:
for j in i:
inv_line_ids.append(j)
res=self.pool.get('account.invoice.line').read(cr, uid, inv_line_ids,['invoice_id'])
res = self.pool.get('account.invoice.line').read(cr, uid,
inv_line_ids,['invoice_id'])
return [x['invoice_id'][0] for x in res if x['invoice_id']]
returned_lines_from_serial()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: