openerp-community-reviewer team mailing list archive
-
openerp-community-reviewer team
-
Mailing list archive
-
Message #03909
[Merge] lp:~camptocamp/openerp-rma/7.0-fix-1282584 into lp:openerp-rma
Yannick Vaucher @ Camptocamp has proposed merging lp:~camptocamp/openerp-rma/7.0-fix-1282584 into lp:openerp-rma.
Commit message:
[FIX] crm_claim_rma - open right view for picking in and picking out instead of internal picking view
Requested reviews:
OpenERP RMA (openerprma)
Related bugs:
Bug #1282584 in OpenERP RMA: "crm_claim_rma - wizard to create picking opens the wrong view"
https://bugs.launchpad.net/openerp-rma/+bug/1282584
For more details, see:
https://code.launchpad.net/~camptocamp/openerp-rma/7.0-fix-1282584/+merge/207450
--
https://code.launchpad.net/~camptocamp/openerp-rma/7.0-fix-1282584/+merge/207450
Your team OpenERP RMA is requested to review the proposed merge of lp:~camptocamp/openerp-rma/7.0-fix-1282584 into lp:openerp-rma.
=== modified file 'crm_claim_rma/__openerp__.py'
--- crm_claim_rma/__openerp__.py 2013-12-12 15:26:26 +0000
+++ crm_claim_rma/__openerp__.py 2014-02-20 14:33:00 +0000
@@ -43,6 +43,8 @@
* product refund
* access to related customer data (orders, invoices, refunds, picking
in/out) from a claim
+* use the OpenERP chatter within team like in opportunity (reply to refer to
+ the team, not a person)
Using this module makes the logistic flow of return this way:
@@ -63,6 +65,7 @@
* Benoît Guillot <benoit.guillot@xxxxxxxxxxxxxxx>
* Joel Grand-Guillaume <joel.grandguillaume@xxxxxxxxxxxxxx>
* Guewen Baconnier <guewen.baconnier@xxxxxxxxxxxxxx>
+ * Yannick Vaucher <yannick.vaucher@xxxxxxxxxxxxxx>
""",
'author': 'Akretion, Camptocamp',
@@ -77,6 +80,7 @@
'security/ir.model.access.csv',
'account_invoice_view.xml',
'stock_view.xml',
+ 'res_partner_view.xml',
'crm_claim_rma_data.xml',
],
'images': ['images/product_return.png',
=== modified file 'crm_claim_rma/account_invoice.py'
--- crm_claim_rma/account_invoice.py 2013-12-03 10:38:43 +0000
+++ crm_claim_rma/account_invoice.py 2014-02-20 14:33:00 +0000
@@ -42,7 +42,7 @@
claim_line_obj = self.pool.get('claim.line')
# check if is an invoice_line and we are from a claim
if not (context.get('claim_line_ids') and lines and
- lines[0]._name =='account.invoice.line'):
+ lines[0]._name == 'account.invoice.line'):
return super(account_invoice, self)._refund_cleanup_lines(
cr, uid, lines, context=None)
=== modified file 'crm_claim_rma/crm_claim_rma.py'
--- crm_claim_rma/crm_claim_rma.py 2013-12-03 10:38:43 +0000
+++ crm_claim_rma/crm_claim_rma.py 2014-02-20 14:33:00 +0000
@@ -23,12 +23,13 @@
import calendar
import math
-from openerp.osv import fields, orm
+from openerp.osv import fields, orm, osv
from datetime import datetime
from dateutil.relativedelta import relativedelta
from openerp.tools import (DEFAULT_SERVER_DATE_FORMAT,
DEFAULT_SERVER_DATETIME_FORMAT)
from openerp.tools.translate import _
+from openerp import SUPERUSER_ID
class substate_substate(orm.Model):
@@ -106,13 +107,13 @@
'product_returned_quantity': fields.float(
'Quantity', digits=(12, 2),
help="Quantity of product returned"),
- 'unit_sale_price' : fields.float(
+ 'unit_sale_price': fields.float(
'Unit sale price', digits=(12, 2),
help="Unit sale price of the product. Auto filled if retrun done "
"by invoice selection. Be careful and check the automatic "
"value as don't take into account previous refunds, invoice "
"discount, can be for 0 if product for free,..."),
- 'return_value' : fields.function(
+ 'return_value': fields.function(
_line_total_amount, string='Total return', type='float',
help="Quantity returned * Unit sold price",),
'prodlot_id': fields.many2one(
@@ -133,23 +134,24 @@
'Warranty',
readonly=True,
help="If warranty has expired"),
- "warranty_type": fields.selection(
+ 'warranty_type': fields.selection(
get_warranty_return_partner,
'Warranty type',
readonly=True,
- help="Who is in charge of the warranty return treatment towards the end customer. "
- "Company will use the current company delivery or default address and so on for "
- "supplier and brand manufacturer. Does not necessarily mean that the warranty to be "
- "applied is the one of the return partner (ie: can be returned to the company and "
- "be under the brand warranty"),
- "warranty_return_partner" : fields.many2one(
+ help="Who is in charge of the warranty return treatment towards "
+ "the end customer. Company will use the current company "
+ "delivery or default address and so on for supplier and brand"
+ " manufacturer. Does not necessarily mean that the warranty "
+ "to be applied is the one of the return partner (ie: can be "
+ "returned to the company and be under the brand warranty"),
+ 'warranty_return_partner': fields.many2one(
'res.partner',
string='Warranty Address',
help="Where the customer has to send back the product(s)"),
'claim_id': fields.many2one(
'crm.claim', string='Related claim',
help="To link to the case.claim object"),
- 'state' : fields.selection(
+ 'state': fields.selection(
[('draft', 'Draft'),
('refused', 'Refused'),
('confirmed', 'Confirmed, waiting for product'),
@@ -160,8 +162,8 @@
'substate_id': fields.many2one(
'substate.substate',
string='Sub state',
- help="Select a sub state to precise the standard state. Example 1: "
- "state = refused; substate could be warranty over, not in "
+ help="Select a sub state to precise the standard state. Example 1:"
+ " state = refused; substate could be warranty over, not in "
"warranty, no problem,... . Example 2: state = to treate; "
"substate could be to refund, to exchange, to repair,..."),
'last_state_change': fields.date(
@@ -245,10 +247,11 @@
warning = _(self.WARRANT_COMMENT['expired'])
else:
warning = _(self.WARRANT_COMMENT['valid'])
- self.write(cr, uid, ids,
- {'guarantee_limit': limit.strftime(DEFAULT_SERVER_DATE_FORMAT),
- 'warning': warning},
- context=context)
+ self.write(
+ cr, uid, ids,
+ {'guarantee_limit': limit.strftime(DEFAULT_SERVER_DATE_FORMAT),
+ 'warning': warning},
+ context=context)
return True
def get_destination_location(self, cr, uid, product_id,
@@ -270,13 +273,14 @@
return location_dest_id
# Method to calculate warranty return address
- def set_warranty_return_address(self, cr, uid, ids, claim_line, context=None):
+ def set_warranty_return_address(self, cr, uid, ids, claim_line,
+ context=None):
"""Return the partner to be used as return destination and
the destination stock location of the line in case of return.
We can have various case here:
- - company or other: return to company partner or crm_return_address_id
- if specified
+ - company or other: return to company partner or
+ crm_return_address_id if specified
- supplier: return to the supplier address
"""
@@ -318,7 +322,8 @@
return True
-#TODO add the option to split the claim_line in order to manage the same product separately
+#TODO add the option to split the claim_line in order to manage the same
+# product separately
class crm_claim(orm.Model):
_inherit = 'crm.claim'
@@ -344,12 +349,14 @@
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))
+ number = claim.number and str(claim.number) or ''
+ res.append((claim.id, '[' + 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)
+ vals['number'] = self._get_sequence_number(cr, uid,
+ context=context)
new_id = super(crm_claim, self).create(cr, uid, vals, context=context)
return new_id
@@ -387,11 +394,16 @@
'planned_cost': fields.float('Expected cost'),
'real_revenue': fields.float('Real revenue'),
'real_cost': fields.float('Real cost'),
- 'invoice_ids': fields.one2many('account.invoice', 'claim_id', 'Refunds'),
+ 'invoice_ids': fields.one2many(
+ 'account.invoice', 'claim_id', 'Refunds'),
'picking_ids': fields.one2many('stock.picking', 'claim_id', 'RMA'),
'invoice_id': fields.many2one(
'account.invoice', string='Invoice',
help='Related original Cusotmer invoice'),
+ 'delivery_address_id': fields.many2one(
+ 'res.partner', string='Partner delivery address',
+ help="This address will be used to deliver repaired or replacement"
+ "products."),
'warehouse_id': fields.many2one(
'stock.warehouse', string='Warehouse',
required=True),
@@ -408,11 +420,14 @@
'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, add, email=email)
+ 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, add,
+ email=email)
if add:
- if not res['value']['email_from'] or not res['value']['partner_phone']:
+ if (not res['value']['email_from']
+ or not res['value']['partner_phone']):
partner_obj = self.pool.get('res.partner')
address = partner_obj.browse(cr, uid, add, context=context)
for other_add in address.partner_id.address:
@@ -422,16 +437,20 @@
res['value']['partner_phone'] = other_add.phone
return res
- def onchange_invoice_id(self, cr, uid, ids, invoice_id, warehouse_id, context=None):
+ def onchange_invoice_id(self, cr, uid, ids, invoice_id, warehouse_id,
+ context=None):
invoice_line_obj = self.pool.get('account.invoice.line')
+ invoice_obj = self.pool.get('account.invoice')
claim_line_obj = self.pool.get('claim.line')
invoice_line_ids = invoice_line_obj.search(
cr, uid,
[('invoice_id', '=', invoice_id)],
context=context)
claim_lines = []
+ value = {}
if not warehouse_id:
- warehouse_id = self._get_default_warehouse(cr, uid, context=context)
+ warehouse_id = self._get_default_warehouse(cr, uid,
+ context=context)
invoice_lines = invoice_line_obj.browse(cr, uid, invoice_line_ids,
context=context)
for invoice_line in invoice_lines:
@@ -448,4 +467,38 @@
'location_dest_id': location_dest_id,
'state': 'draft',
})
- return {'value': {'claim_line_ids': claim_lines}}
+ value = {'claim_line_ids': claim_lines}
+ delivery_address_id = False
+ if invoice_id:
+ invoice = invoice_obj.browse(cr, uid, invoice_id, context=context)
+ delivery_address_id = invoice.partner_id.id
+ value['delivery_address_id'] = delivery_address_id
+
+ return {'value': value}
+
+ def message_get_reply_to(self, cr, uid, ids, context=None):
+ """ Override to get the reply_to of the parent project. """
+ return [claim.section_id.message_get_reply_to()[0]
+ if claim.section_id else False
+ for claim in self.browse(cr, SUPERUSER_ID, ids,
+ context=context)]
+
+ def message_get_suggested_recipients(self, cr, uid, ids, context=None):
+ recipients = super(crm_claim, self
+ ).message_get_suggested_recipients(cr, uid, ids,
+ context=context)
+ try:
+ for claim in self.browse(cr, uid, ids, context=context):
+ if claim.partner_id:
+ self._message_add_suggested_recipient(
+ cr, uid, recipients, claim,
+ partner=claim.partner_id, reason=_('Customer'))
+ elif claim.email_from:
+ self._message_add_suggested_recipient(
+ cr, uid, recipients, claim,
+ email=claim.email_from, reason=_('Customer Email'))
+ except (osv.except_osv, orm.except_orm):
+ # no read access rights -> just ignore suggested recipients
+ # because this imply modifying followers
+ pass
+ return recipients
=== modified file 'crm_claim_rma/crm_claim_rma_view.xml'
--- crm_claim_rma/crm_claim_rma_view.xml 2013-12-13 12:45:43 +0000
+++ crm_claim_rma/crm_claim_rma_view.xml 2014-02-20 14:33:00 +0000
@@ -166,6 +166,7 @@
<separator string="Product Return" colspan="4"/>
<group>
<field name="invoice_id" on_change="onchange_invoice_id(invoice_id,warehouse_id,context)" domain="['|',('commercial_partner_id','=',partner_id),('partner_id','=',partner_id)]" />
+ <field name="delivery_address_id" context="{'tree_view_ref': 'crm_claim_rma.view_partner_contact_tree', 'search_default_parent_id': partner_id}"/>
</group>
<group>
<!-- Place for mass return button from crm_rma_lot_mass_return -->
@@ -247,14 +248,14 @@
domain="[('type', '=', 'in')]"
id="act_crm_claim_rma_picking_in"
name="Incomming Shipment and Returns"
- res_model="stock.picking"
+ res_model="stock.picking.in"
src_model="crm.claim"/>
<!-- Right side link to picking out -->
<act_window
domain="[('type', '=', 'out')]"
id="act_crm_claim_rma_picking_out"
name="Deliveries"
- res_model="stock.picking"
+ res_model="stock.picking.out"
src_model="crm.claim"/>
<record model="ir.ui.view" id="crm_claim_rma_form_view2">
=== added file 'crm_claim_rma/res_partner_view.xml'
--- crm_claim_rma/res_partner_view.xml 1970-01-01 00:00:00 +0000
+++ crm_claim_rma/res_partner_view.xml 2014-02-20 14:33:00 +0000
@@ -0,0 +1,25 @@
+<?xml version="1.0"?>
+<openerp>
+ <data>
+ <!-- Address list with details to help shipping address selection -->
+ <record id="view_partner_contact_tree" model="ir.ui.view">
+ <field name="name">res.partner.contact.tree</field>
+ <field name="model">res.partner</field>
+ <field name="arch" type="xml">
+ <tree string="Contacts">
+ <field name="name"/>
+ <field name="function" invisible="1"/>
+ <field name="street"/>
+ <field name="zip"/>
+ <field name="city"/>
+ <field name="email"/>
+ <field name="user_id" invisible="1"/>
+ <field name="is_company" invisible="1"/>
+ <field name="country" invisible="1"/>
+ <field name="country_id"/>
+ <field name="parent_id" invisible="1"/>
+ </tree>
+ </field>
+ </record>
+ </data>
+</openerp>
=== modified file 'crm_claim_rma/stock.py'
--- crm_claim_rma/stock.py 2013-12-03 10:38:43 +0000
+++ crm_claim_rma/stock.py 2014-02-20 14:33:00 +0000
@@ -54,7 +54,7 @@
}
-class stock_picking_out(orm.Model):
+class stock_picking_in(orm.Model):
_inherit = "stock.picking.in"
@@ -72,7 +72,8 @@
_inherit = "stock.move"
def create(self, cr, uid, vals, context=None):
- move_id = super(stock_move, self).create(cr, uid, vals, context=context)
+ move_id = super(stock_move, self
+ ).create(cr, uid, vals, context=context)
if vals.get('picking_id'):
picking_obj = self.pool.get('stock.picking')
picking = picking_obj.browse(cr, uid, vals['picking_id'],
=== modified file 'crm_claim_rma/wizard/account_invoice_refund.py'
--- crm_claim_rma/wizard/account_invoice_refund.py 2013-12-03 10:38:43 +0000
+++ crm_claim_rma/wizard/account_invoice_refund.py 2014-02-20 14:33:00 +0000
@@ -29,7 +29,7 @@
def compute_refund(self, cr, uid, ids, mode='refund', context=None):
if context is None:
- context={}
+ context = {}
if context.get('invoice_ids'):
context['active_ids'] = context.get('invoice_ids')
return super(account_invoice_refund, self).compute_refund(
=== modified file 'crm_claim_rma/wizard/claim_make_picking.py'
--- crm_claim_rma/wizard/claim_make_picking.py 2013-12-03 10:38:43 +0000
+++ crm_claim_rma/wizard/claim_make_picking.py 2014-02-20 14:33:00 +0000
@@ -20,7 +20,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
-from openerp.osv import fields, orm, osv
+from openerp.osv import fields, orm
from openerp.tools import DEFAULT_SERVER_DATETIME_FORMAT
from openerp import netsvc
from openerp.tools.translate import _
@@ -51,7 +51,8 @@
}
def _get_claim_lines(self, cr, uid, context):
- #TODO use custom states to show buttons of this wizard or not instead of raise an error
+ #TODO use custom states to show buttons of this wizard or not instead
+ # of raise an error
if context is None:
context = {}
line_obj = self.pool.get('claim.line')
@@ -112,7 +113,8 @@
line_obj = self.pool.get('claim.line')
line_partner = []
for line in line_obj.browse(cr, uid, line_ids, context=context):
- if (line.warranty_return_partner and line.warranty_return_partner.id
+ if (line.warranty_return_partner
+ and line.warranty_return_partner.id
not in line_partner):
line_partner.append(line.warranty_return_partner.id)
if len(line_partner) == 1:
@@ -123,8 +125,8 @@
def _get_dest_loc(self, cr, uid, context):
"""Return the location_id to use as destination.
If it's an outoing shippment: take the customer stock property
- If it's an incomming shippment take the location_dest_id common to all lines, or
- if different, return None."""
+ If it's an incomming shippment take the location_dest_id common to all
+ lines, or if different, return None."""
if context is None:
context = {}
loc_id = False
@@ -162,27 +164,23 @@
write_field = 'move_out_id'
note = 'RMA picking out'
view_xml_id = 'stock_picking_form'
- view_name = 'stock.picking.form'
else:
p_type = 'in'
- view_xml_id = 'stock_picking_form'
- view_name = 'stock.picking.form'
write_field = 'move_in_id'
if context.get('picking_type'):
note = 'RMA picking ' + str(context.get('picking_type'))
name = note
+ model = 'stock.picking.' + p_type
view_id = view_obj.search(cr, uid,
- [('xml_id', '=', view_xml_id),
- ('model', '=', 'stock.picking'),
+ [('model', '=', model),
('type', '=', 'form'),
- ('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)
- partner_id = claim.partner_id.id
+ partner_id = claim.delivery_address_id.id
line_ids = [x.id for x in wizard.claim_line_ids]
# In case of product return, we don't allow one picking for various
# product if location are different
@@ -220,7 +218,7 @@
'location_dest_id': wizard.claim_line_dest_location.id,
'note': note,
'claim_id': claim.id,
- },
+ },
context=context)
# Create picking lines
for wizard_claim_line in wizard.claim_line_ids:
@@ -261,7 +259,7 @@
'view_mode': 'form',
'view_id': view_id,
'domain': domain,
- 'res_model': 'stock.picking',
+ 'res_model': model,
'res_id': picking_id,
'type': 'ir.actions.act_window',
}
Follow ups