[9.0] rma:

* proper link between customer and supplier rma.
 * fix wizard for generating supplier rma.
 * several view issues.
This commit is contained in:
Lois Rilo
2018-05-14 14:58:42 +02:00
parent 37a4146c05
commit a836a72bee
4 changed files with 78 additions and 19 deletions

View File

@@ -158,6 +158,13 @@ class RmaOrderLine(models.Model):
rec.procurement_count = len(rec.procurement_ids.filtered(
lambda p: p.state == 'exception'))
@api.multi
def _compute_rma_line_count(self):
for rec in self.filtered(lambda r: r.type == 'customer'):
rec.rma_line_count = len(rec.supplier_rma_line_ids)
for rec in self.filtered(lambda r: r.type == 'supplier'):
rec.rma_line_count = len(rec.customer_rma_id)
delivery_address_id = fields.Many2one(
comodel_name='res.partner', string='Partner delivery address',
default=_default_delivery_address,
@@ -313,11 +320,21 @@ class RmaOrderLine(models.Model):
'rma.order.line', string='Customer RMA line', ondelete='cascade')
supplier_rma_line_ids = fields.One2many(
'rma.order.line', 'customer_rma_id')
rma_line_count = fields.Integer(
compute='_compute_rma_line_count',
string='# of RMA lines associated',
)
supplier_address_id = fields.Many2one(
'res.partner', readonly=True,
comodel_name='res.partner', readonly=True,
states={'draft': [('readonly', False)]},
string='Supplier Address',
help="This address of the supplier in case of Customer RMA operation "
help="Address of the supplier in case of Customer RMA operation "
"dropship.")
customer_address_id = fields.Many2one(
comodel_name='res.partner', readonly=True,
states={'draft': [('readonly', False)]},
string='Customer Address',
help="Address of the customer in case of Supplier RMA operation "
"dropship.")
qty_to_receive = fields.Float(
string='Qty To Receive',
@@ -601,3 +618,26 @@ class RmaOrderLine(models.Model):
result['views'] = [(res and res.id or False, 'form')]
result['res_id'] = procurements[0]
return result
@api.multi
def action_view_rma_lines(self):
if self.type == 'customer':
# from customer we link to supplier rma
action = self.env.ref(
'rma.action_rma_supplier_lines')
rma_lines = self.supplier_rma_line_ids.ids
res = self.env.ref('rma.view_rma_line_supplier_form', False)
else:
# from supplier we link to customer rma
action = self.env.ref(
'rma.action_rma_customer_lines')
rma_lines = self.customer_rma_id.ids
res = self.env.ref('rma.view_rma_line_form', False)
result = action.read()[0]
# choose the view_mode accordingly
if len(rma_lines) != 1:
result['domain'] = rma_lines.ids
elif len(rma_lines) == 1:
result['views'] = [(res and res.id or False, 'form')]
result['res_id'] = rma_lines[0]
return result

View File

@@ -90,6 +90,13 @@
<field name="procurement_count" widget="statinfo"
string="Proc. Exceptions"/>
</button>
<button type="object" name="action_view_rma_lines"
class="oe_stat_button"
icon="fa-link"
groups="stock.group_stock_user">
<field name="rma_line_count" widget="statinfo"
string="Customer RMA"/>
</button>
</div>
<div class="oe_title" name="title">
<h1>
@@ -139,21 +146,24 @@
<page name="description" string="Description">
<field name="description" nolabel="1"/>
</page>
<page name="route" string="Routes" groups="stock.group_adv_location">
<page name="route" string="Routes">
<group>
<group>
<group name="inbound" string="Inbound">
<field name="in_warehouse_id"/>
<field name="location_id"
domain="[('usage', '=', 'internal')]"/>
<field name="in_route_id"/>
<field name="supplier_to_customer"/>
<field name="in_route_id" groups="stock.group_adv_location"/>
</group>
<group name="outbound" string="Outbound">
<field name="out_warehouse_id"/>
<field name="delivery_address_id"
groups='rma.group_rma_delivery_invoice_address'/>
<field name="out_route_id"/>
<field name="out_route_id" groups="stock.group_adv_location"/>
<field name="supplier_to_customer"/>
<field name="customer_address_id"
attrs="{'required':[('supplier_to_customer', '=', True)],
'invisible':[('supplier_to_customer', '=', False)]}"/>
</group>
</group>
</group>
@@ -199,10 +209,10 @@
</record>
<record id="view_rma_line_form" model="ir.ui.view">
<field name="name">rma.order.line.form</field>
<field name="name">rma.order.line.customer.form</field>
<field name="model">rma.order.line</field>
<field name="arch" type="xml">
<form string="Rma Line">
<form string="RMA Line">
<header>
<button name="action_rma_to_approve" type="object"
string="Request Approval"
@@ -237,11 +247,6 @@
<field name="out_shipment_count" widget="statinfo"
string="Deliveries"/>
</button>
<button type="object" name="action_view_invoice"
class="oe_stat_button"
icon="fa-pencil-square-o"
string="Origin Inv">
</button>
<button type="object" name="action_view_procurements"
class="oe_stat_button"
icon="fa-warning"
@@ -249,6 +254,13 @@
<field name="procurement_count" widget="statinfo"
string="Exceptions"/>
</button>
<button type="object" name="action_view_rma_lines"
class="oe_stat_button"
icon="fa-link"
groups="stock.group_stock_user">
<field name="rma_line_count" widget="statinfo"
string="Supplier RMA"/>
</button>
</div>
<div class="oe_title" name="title">
<h1>
@@ -306,7 +318,7 @@
<field name="in_warehouse_id"/>
<field name="location_id"
domain="[('usage', '=', 'internal')]"/>
<field name="in_route_id"/>
<field name="in_route_id" groups="stock.group_adv_location"/>
<field name="customer_to_supplier"/>
<field name="supplier_address_id"
attrs="{'required':[('customer_to_supplier', '=', True)],
@@ -316,7 +328,7 @@
<field name="out_warehouse_id"/>
<field name="delivery_address_id"
groups='rma.group_rma_delivery_invoice_address'/>
<field name="out_route_id"/>
<field name="out_route_id" groups="stock.group_adv_location"/>
</group>
</group>
</group>

View File

@@ -78,6 +78,8 @@ class RmaMakePicking(models.TransientModel):
def _get_address(self, item):
if item.line_id.customer_to_supplier:
delivery_address = item.line_id.supplier_address_id
elif item.line_id.supplier_to_customer:
delivery_address = item.line_id.customer_address_id
elif item.line_id.delivery_address_id:
delivery_address = item.line_id.delivery_address_id
elif item.line_id.partner_id:
@@ -106,8 +108,12 @@ class RmaMakePicking(models.TransientModel):
warehouse = line.in_warehouse_id
route = line.in_route_id
else:
location = self._get_address_location(
delivery_address_id, line.type)
if line.supplier_to_customer:
location = self._get_address_location(
delivery_address_id, 'customer')
else:
location = self._get_address_location(
delivery_address_id, line.type)
warehouse = line.out_warehouse_id
route = line.out_route_id
if not route:

View File

@@ -108,8 +108,9 @@ class RmaLineMakeSupplierRma(models.TransientModel):
'partner_id': self.partner_id.id,
'type': 'supplier',
'origin': item.line_id.rma_id.name,
'delivery_address_id':
item.line_id.delivery_address_id.id,
'customer_address_id':
item.line_id.delivery_address_id.id or
item.line_id.partner_id.id,
'product_id': item.line_id.product_id.id,
'customer_rma_id': item.line_id.id,
'product_qty': item.product_qty,