From 14e110689d16bd3e642d90906c2ce256c466af0a Mon Sep 17 00:00:00 2001 From: Thibault Francois Date: Sat, 1 Dec 2018 17:34:53 +0100 Subject: [PATCH] [CHANGE][0045 - Date de livraison dans le bon de commande] Remove date_planned and button to set date in tab delivery Add a new field manual_date_planned Onchange on order_line to set the first time a date planned Force the manual_date_planned to all line at confirmation Change the report for purchase order [ADD] default value on picking responsible: set the create_uid as responsible (this mean the one that confirm the purchase order --- beesdoo_inventory/models/stock.py | 2 +- beesdoo_purchase/__init__.py | 3 +- beesdoo_purchase/models/purchase.py | 5 --- beesdoo_purchase/views/purchase_order.xml | 3 -- .../__init__.py | 2 ++ .../__openerp__.py | 31 +++++++++++++++++++ .../models/__init__.py | 0 .../models/purchase.py | 28 +++++++++++++++++ .../report/report_purchaseorder.xml | 18 +++++++++++ .../views/purchase_order.xml | 23 ++++++++++++++ 10 files changed, 104 insertions(+), 11 deletions(-) delete mode 100644 beesdoo_purchase/models/purchase.py create mode 100644 beesdoo_purchase_manual_date_planned/__init__.py create mode 100644 beesdoo_purchase_manual_date_planned/__openerp__.py rename {beesdoo_purchase => beesdoo_purchase_manual_date_planned}/models/__init__.py (100%) create mode 100644 beesdoo_purchase_manual_date_planned/models/purchase.py create mode 100644 beesdoo_purchase_manual_date_planned/report/report_purchaseorder.xml create mode 100644 beesdoo_purchase_manual_date_planned/views/purchase_order.xml diff --git a/beesdoo_inventory/models/stock.py b/beesdoo_inventory/models/stock.py index cf09b0f..6016de3 100644 --- a/beesdoo_inventory/models/stock.py +++ b/beesdoo_inventory/models/stock.py @@ -5,7 +5,7 @@ class StockPicking(models.Model): _inherit = 'stock.picking' max_shipping_date = fields.Datetime("End Shipping Date") - responsible = fields.Many2one('res.partner', string="Responsible") + responsible = fields.Many2one('res.partner', string="Responsible", default=lambda self: self.env.user.partner_id.id) def _add_follower(self): if(self.responsible): diff --git a/beesdoo_purchase/__init__.py b/beesdoo_purchase/__init__.py index 0f7cb6b..7c68785 100644 --- a/beesdoo_purchase/__init__.py +++ b/beesdoo_purchase/__init__.py @@ -1,2 +1 @@ -# -*- coding: utf-8 -*- -import models \ No newline at end of file +# -*- coding: utf-8 -*- \ No newline at end of file diff --git a/beesdoo_purchase/models/purchase.py b/beesdoo_purchase/models/purchase.py deleted file mode 100644 index dcc670e..0000000 --- a/beesdoo_purchase/models/purchase.py +++ /dev/null @@ -1,5 +0,0 @@ -# -*- coding: utf-8 -*- -from openerp import models, api - -class PurchaseOrder(models.Model): - _inherit = 'purchase.order' diff --git a/beesdoo_purchase/views/purchase_order.xml b/beesdoo_purchase/views/purchase_order.xml index f38d4fc..f55c47c 100644 --- a/beesdoo_purchase/views/purchase_order.xml +++ b/beesdoo_purchase/views/purchase_order.xml @@ -8,9 +8,6 @@ [('main_seller_id','=', parent.partner_id)] - - 0 - diff --git a/beesdoo_purchase_manual_date_planned/__init__.py b/beesdoo_purchase_manual_date_planned/__init__.py new file mode 100644 index 0000000..0f7cb6b --- /dev/null +++ b/beesdoo_purchase_manual_date_planned/__init__.py @@ -0,0 +1,2 @@ +# -*- coding: utf-8 -*- +import models \ No newline at end of file diff --git a/beesdoo_purchase_manual_date_planned/__openerp__.py b/beesdoo_purchase_manual_date_planned/__openerp__.py new file mode 100644 index 0000000..db3a678 --- /dev/null +++ b/beesdoo_purchase_manual_date_planned/__openerp__.py @@ -0,0 +1,31 @@ +# -*- coding: utf-8 -*- +{ + 'name': "Bees Purchase Manual date planned", + + 'summary': """ + Extension du module Purchase to set manually the date planned for the whole purchase.order""", + + 'description': """ + Long description of module's purpose + """, + + 'author': "Beescoop - Cellule IT", + 'website': "https://github.com/beescoop/Obeesdoo", + + # Categories can be used to filter modules in modules listing + # Check https://github.com/odoo/odoo/blob/master/openerp/addons/base/module/module_data.xml + # for the full list + 'category': 'Purchase', + 'version': '0.1', + + # any module necessary for this one to work correctly + 'depends': ['purchase'], + + # always loaded + 'data': [ + 'views/purchase_order.xml', + 'report/report_purchaseorder.xml', + ], + # only loaded in demonstration mode + 'demo': [], +} \ No newline at end of file diff --git a/beesdoo_purchase/models/__init__.py b/beesdoo_purchase_manual_date_planned/models/__init__.py similarity index 100% rename from beesdoo_purchase/models/__init__.py rename to beesdoo_purchase_manual_date_planned/models/__init__.py diff --git a/beesdoo_purchase_manual_date_planned/models/purchase.py b/beesdoo_purchase_manual_date_planned/models/purchase.py new file mode 100644 index 0000000..45a386d --- /dev/null +++ b/beesdoo_purchase_manual_date_planned/models/purchase.py @@ -0,0 +1,28 @@ +# -*- coding: utf-8 -*- +from openerp import models, api, fields + +class PurchaseOrder(models.Model): + _inherit = 'purchase.order' + + manual_date_planned = fields.Datetime(string='Scheduled Date', required=True) + + @api.onchange('order_line', 'order_line.date_planned') + def _on_change_manual_date_planned(self): + """ + Since we don't see the date planned on the line anymore + give an idea of the user by setting the first date planned of the lines + """ + for line in self.order_line: + if line.date_planned and not self.manual_date_planned: + self.manual_date_planned = line.date_planned + break; + + @api.multi + def button_confirm(self): + """ + Since we hide the button to set the date planned on all line and we + hide them, we call the method to set the date planned on the line at the confirmation + """ + self.ensure_one() + self.with_context(date_planned=self.manual_date_planned).action_set_date_planned() + return super(PurchaseOrder, self).button_confirm() diff --git a/beesdoo_purchase_manual_date_planned/report/report_purchaseorder.xml b/beesdoo_purchase_manual_date_planned/report/report_purchaseorder.xml new file mode 100644 index 0000000..d640001 --- /dev/null +++ b/beesdoo_purchase_manual_date_planned/report/report_purchaseorder.xml @@ -0,0 +1,18 @@ + + + + + + diff --git a/beesdoo_purchase_manual_date_planned/views/purchase_order.xml b/beesdoo_purchase_manual_date_planned/views/purchase_order.xml new file mode 100644 index 0000000..34dda02 --- /dev/null +++ b/beesdoo_purchase_manual_date_planned/views/purchase_order.xml @@ -0,0 +1,23 @@ + + + + beesdoo.purchase.order.form.view + purchase.order + + + + 1 + + + 1 + + + 1 + + + + + + + +