From c7debd2edb48f105a2f92bf19f9eab0dd360dbff Mon Sep 17 00:00:00 2001 From: JF Aubert Date: Thu, 8 Oct 2020 09:10:51 +0000 Subject: [PATCH] [IMP] stock : Improve general usability Purchase - When a RFQ is in "To Approve" stage, on the printed pdf, keep "Request for Quotation" as a title - "Send Reminder" action should open the composer when triggered manually. Inventory - In tree view of transfer, set date_done optional = hide - In (mobile) picking view, replace button text with 'add a product' - fix Vendor Group by in Replenishment report - Warning message when changing product tracking from untracked to tracked MRP - Reporting > Manufacturing Orders : change measure for total quantity grouped by scheduled date = month and by product - Reporting > Work Orders : change measure for Duration per unit grouped by workcenter and by product & add unit (minutes) - Reporting > Overall equipment effectiveness : group by loss reason added to the current group by workcenter closes odoo/odoo#57036 Related: odoo/enterprise#12926 Signed-off-by: William Henrotin --- addons/mrp/views/mrp_production_views.xml | 4 +- addons/mrp/views/mrp_workcenter_views.xml | 10 ++--- addons/mrp/views/mrp_workorder_views.xml | 17 +++++--- addons/purchase/models/purchase.py | 42 ++++++++++++++++++- .../report/purchase_order_templates.xml | 3 +- addons/purchase_stock/models/stock.py | 3 +- addons/stock/models/product.py | 13 +++--- addons/stock/views/stock_picking_views.xml | 6 ++- 8 files changed, 73 insertions(+), 25 deletions(-) diff --git a/addons/mrp/views/mrp_production_views.xml b/addons/mrp/views/mrp_production_views.xml index 87464dfd365..4488062e005 100644 --- a/addons/mrp/views/mrp_production_views.xml +++ b/addons/mrp/views/mrp_production_views.xml @@ -448,8 +448,9 @@ mrp.production.graph mrp.production - + + @@ -555,6 +556,7 @@ mrp.production graph,pivot,form current + {'search_default_scheduled_date': 1, 'search_default_product': 2, 'default_company_id': allowed_company_ids[0]}

No data yet! diff --git a/addons/mrp/views/mrp_workcenter_views.xml b/addons/mrp/views/mrp_workcenter_views.xml index 1e98917336c..d36093a23cf 100644 --- a/addons/mrp/views/mrp_workcenter_views.xml +++ b/addons/mrp/views/mrp_workcenter_views.xml @@ -72,7 +72,7 @@ - + @@ -125,7 +125,7 @@ ir.actions.act_window mrp.workorder [] - {'search_default_done': True} + {'search_default_workcenter': 1, 'search_default_product': 2} graph,pivot,tree,form,gantt @@ -566,7 +566,7 @@ - + @@ -578,7 +578,7 @@ - + @@ -589,7 +589,7 @@ mrp.workcenter.productivity graph,pivot,tree,form [] - {'search_default_workcenter_group': 1, 'search_default_thismonth':True, 'create':False,'edit':False} + {'search_default_workcenter_group': 1, 'search_default_loss_group': 2, 'create':False,'edit':False}

Overall Equipment Effectiveness: no working or blocked time diff --git a/addons/mrp/views/mrp_workorder_views.xml b/addons/mrp/views/mrp_workorder_views.xml index 8f22cea7d29..6776385e25c 100644 --- a/addons/mrp/views/mrp_workorder_views.xml +++ b/addons/mrp/views/mrp_workorder_views.xml @@ -14,6 +14,10 @@ + + + + @@ -257,9 +261,11 @@ mrp.production.work.order.graph mrp.workorder - + - + + + @@ -271,7 +277,8 @@ - + + @@ -470,7 +477,7 @@ mrp.workorder - + @@ -484,7 +491,7 @@ - + diff --git a/addons/purchase/models/purchase.py b/addons/purchase/models/purchase.py index f4b6c08ebd6..5bfc7dfa788 100644 --- a/addons/purchase/models/purchase.py +++ b/addons/purchase/models/purchase.py @@ -660,7 +660,10 @@ class PurchaseOrder(models.Model): for order in orders: date = order.date_planned if date and (send_single or (date - relativedelta(days=order.reminder_date_before_receipt)).date() == datetime.today().date()): - order.with_context(is_reminder=True).message_post_with_template(template.id, email_layout_xmlid="mail.mail_notification_paynow", composition_mode='comment') + if send_single: + return order._send_reminder_open_composer(template.id) + else: + order.with_context(is_reminder=True).message_post_with_template(template.id, email_layout_xmlid="mail.mail_notification_paynow", composition_mode='comment') def send_reminder_preview(self): self.ensure_one() @@ -677,6 +680,43 @@ class PurchaseOrder(models.Model): notif_layout="mail.mail_notification_paynow") return {'toast_message': _("A sample email has been sent to %s.") % self.env.user.email} + def _send_reminder_open_composer(self,template_id): + self.ensure_one() + try: + compose_form_id = self.env['ir.model.data'].get_object_reference('mail', 'email_compose_message_wizard_form')[1] + except ValueError: + compose_form_id = False + ctx = dict(self.env.context or {}) + ctx.update({ + 'default_model': 'purchase.order', + 'active_model': 'purchase.order', + 'active_id': self.ids[0], + 'default_res_id': self.ids[0], + 'default_use_template': bool(template_id), + 'default_template_id': template_id, + 'default_composition_mode': 'comment', + 'custom_layout': "mail.mail_notification_paynow", + 'force_email': True, + 'mark_rfq_as_sent': True, + }) + lang = self.env.context.get('lang') + if {'default_template_id', 'default_model', 'default_res_id'} <= ctx.keys(): + template = self.env['mail.template'].browse(ctx['default_template_id']) + if template and template.lang: + lang = template._render_lang([ctx['default_res_id']])[ctx['default_res_id']] + self = self.with_context(lang=lang) + ctx['model_description'] = _('Purchase Order') + return { + 'name': _('Compose Email'), + 'type': 'ir.actions.act_window', + 'view_mode': 'form', + 'res_model': 'mail.compose.message', + 'views': [(compose_form_id, 'form')], + 'view_id': compose_form_id, + 'target': 'new', + 'context': ctx, + } + @api.model def _get_orders_to_remind(self): """When auto sending a reminder mail, only send for unconfirmed purchase diff --git a/addons/purchase/report/purchase_order_templates.xml b/addons/purchase/report/purchase_order_templates.xml index 8ca91d26ddc..c815e2de9b4 100644 --- a/addons/purchase/report/purchase_order_templates.xml +++ b/addons/purchase/report/purchase_order_templates.xml @@ -21,8 +21,7 @@

-

Request for Quotation #

-

Purchase Order #

+

Request for Quotation #

Purchase Order #

Cancelled Purchase Order #

diff --git a/addons/purchase_stock/models/stock.py b/addons/purchase_stock/models/stock.py index 526c96f124c..c2f938576ab 100644 --- a/addons/purchase_stock/models/stock.py +++ b/addons/purchase_stock/models/stock.py @@ -180,8 +180,9 @@ class Orderpoint(models.Model): show_supplier = fields.Boolean('Show supplier column', compute='_compute_show_suppplier') supplier_id = fields.Many2one( - 'product.supplierinfo', string='Vendor', check_company=True, + 'product.supplierinfo', string='Product Supplier', check_company=True, domain="['|', ('product_id', '=', product_id), '&', ('product_id', '=', False), ('product_tmpl_id', '=', product_tmpl_id)]") + vendor_id = fields.Many2one(related='supplier_id.name', string="Vendor", store=True) @api.depends('product_id.purchase_order_line_ids', 'product_id.purchase_order_line_ids.state') def _compute_qty(self): diff --git a/addons/stock/models/product.py b/addons/stock/models/product.py index f7251811fec..f9d0c7c7de8 100644 --- a/addons/stock/models/product.py +++ b/addons/stock/models/product.py @@ -363,14 +363,11 @@ class Product(models.Model): @api.onchange('tracking') def onchange_tracking(self): - products = self.filtered(lambda self: self.tracking and self.tracking != 'none') - if products: - unassigned_quants = self.env['stock.quant'].search_count([('product_id', 'in', products.ids), ('lot_id', '=', False), ('location_id.usage','=', 'internal')]) - if unassigned_quants: - return { - 'warning': { - 'title': _('Warning!'), - 'message': _("You have product(s) in stock that have no lot/serial number. You can assign lot/serial numbers by doing an inventory adjustment.")}} + if self.tracking != "none" and self.qty_available > 0: + return { + 'warning': { + 'title': _('Warning!'), + 'message': _("You have product(s) in stock that have no lot/serial number. You can assign lot/serial numbers by doing an inventory adjustment.")}} @api.model def view_header_get(self, view_id, view_type): diff --git a/addons/stock/views/stock_picking_views.xml b/addons/stock/views/stock_picking_views.xml index 163d6eef114..deb7cee5cbf 100644 --- a/addons/stock/views/stock_picking_views.xml +++ b/addons/stock/views/stock_picking_views.xml @@ -185,6 +185,7 @@ + @@ -334,7 +335,8 @@ + context="{'default_company_id': company_id, 'default_date': scheduled_date, 'default_date_deadline': date_deadline, 'picking_type_code': picking_type_code, 'default_picking_id': id, 'form_view_ref':'stock.view_move_form', 'address_in_id': partner_id, 'default_picking_type_id': picking_type_id, 'default_location_id': location_id, 'default_location_dest_id': location_dest_id}" + options="{'create_text':'Add a Product'}"> @@ -644,7 +646,7 @@ stock.picking.type.kanban stock.picking.type - +