port to 18.0 of durpro module for pneumac
This commit is contained in:
parent
3f2414a415
commit
32ab90c173
7 changed files with 114 additions and 0 deletions
1
current_user_as_invoice_user/__init__.py
Normal file
1
current_user_as_invoice_user/__init__.py
Normal file
|
|
@ -0,0 +1 @@
|
|||
from . import wizard
|
||||
30
current_user_as_invoice_user/__manifest__.py
Normal file
30
current_user_as_invoice_user/__manifest__.py
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
#
|
||||
# Bemade Inc.
|
||||
#
|
||||
# Copyright (C) 2023-June Bemade Inc. (<https://www.bemade.org>).
|
||||
# Author: Marc Durepos (Contact : marc@bemade.org)
|
||||
#
|
||||
# This program is under the terms of the Odoo Proprietary License v1.0 (OPL-1)
|
||||
# It is forbidden to publish, distribute, sublicense, or sell copies of the Software
|
||||
# or modified copies of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
# DEALINGS IN THE SOFTWARE.
|
||||
#
|
||||
{
|
||||
'name': 'Current User as Invoice User',
|
||||
'version': '18.0.1.0.0',
|
||||
'summary': 'Instead of the salesperson, use the currently logged in user as the responsible user on invoice.',
|
||||
'category': 'Accounting',
|
||||
'author': 'Bemade Inc.',
|
||||
'website': 'http://www.bemade.org',
|
||||
'license': 'OPL-1',
|
||||
'depends': ['sale', 'account'],
|
||||
'installable': True,
|
||||
'auto_install': False,
|
||||
}
|
||||
1
current_user_as_invoice_user/tests/__init__.py
Normal file
1
current_user_as_invoice_user/tests/__init__.py
Normal file
|
|
@ -0,0 +1 @@
|
|||
from . import test_current_user_as_invoice_user
|
||||
|
|
@ -0,0 +1,52 @@
|
|||
from odoo.tests import TransactionCase, Form, tagged
|
||||
from odoo.addons.sale.tests.common import TestSaleCommon
|
||||
from odoo import Command
|
||||
|
||||
|
||||
@tagged("-at_install", "post_install")
|
||||
class TestSaleOrder(TestSaleCommon):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super().setUpClass()
|
||||
Partner = cls.env['res.partner']
|
||||
groups = [
|
||||
cls.env.ref('base.group_user').id,
|
||||
cls.env.ref('base.group_system').id,
|
||||
cls.env.ref('account.group_account_invoice').id,
|
||||
cls.env.ref('sales_team.group_sale_manager').id,
|
||||
]
|
||||
cls.user = cls.env['res.users'].create({
|
||||
'partner_id': Partner.create({'name': 'user1'}).id,
|
||||
'login': 'test_user',
|
||||
'password': 'test_user',
|
||||
'groups_id': [Command.set(groups)]
|
||||
})
|
||||
cls.product = cls.env['product.product'].create({
|
||||
'name': 'Test Product',
|
||||
'default_code': 'TEST',
|
||||
'list_price': 10.0,
|
||||
'invoice_policy': 'order',
|
||||
})
|
||||
cls.sale_order = cls.env['sale.order'].with_user(cls.user).create({
|
||||
'partner_id': cls.partner_a.id,
|
||||
})
|
||||
so_form = Form(cls.sale_order)
|
||||
with so_form.order_line.new() as line:
|
||||
line.product_id = cls.product
|
||||
line.product_uom_qty = 2
|
||||
so_form.save()
|
||||
cls.sale_order.action_confirm()
|
||||
|
||||
def test_invoice_wizard_does_not_set_so_responsible_as_invoice_follower(self):
|
||||
so = self.sale_order
|
||||
admin = self.env.ref('base.user_root')
|
||||
wiz = self.env['sale.advance.payment.inv'].with_user(admin).with_context({
|
||||
'active_ids': so.ids,
|
||||
'active_model': 'sale.order',
|
||||
}).create({})
|
||||
wiz.with_user(admin).create_invoices()
|
||||
invoice = so.invoice_ids[0]
|
||||
self.assertEqual(invoice.invoice_user_id, admin)
|
||||
self.assertFalse(self.user in invoice.message_follower_ids.mapped('partner_id').mapped('user_ids'))
|
||||
|
||||
|
||||
2
current_user_as_invoice_user/wizard/__init__.py
Normal file
2
current_user_as_invoice_user/wizard/__init__.py
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
from . import sale_make_invoice_advance
|
||||
from . import sale_order
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
from odoo import models
|
||||
|
||||
|
||||
class SaleMakeInvoiceAdvance(models.TransientModel):
|
||||
_inherit = "sale.advance.payment.inv"
|
||||
|
||||
def _prepare_invoice_values(self, order, so_line):
|
||||
invoice_vals = super()._prepare_invoice_values(order, so_line)
|
||||
invoice_vals.update(
|
||||
{
|
||||
"invoice_user_id": self.env.user.id,
|
||||
"user_id": self.env.user.id,
|
||||
}
|
||||
)
|
||||
return invoice_vals
|
||||
13
current_user_as_invoice_user/wizard/sale_order.py
Normal file
13
current_user_as_invoice_user/wizard/sale_order.py
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
from odoo import models, fields, api, _
|
||||
|
||||
|
||||
class SaleOrder(models.Model):
|
||||
_inherit = "sale.order"
|
||||
|
||||
def _prepare_invoice(self):
|
||||
invoice_vals = super()._prepare_invoice()
|
||||
invoice_vals.update({
|
||||
'invoice_user_id': self.env.user.id,
|
||||
'user_id': self.env.user.id,
|
||||
})
|
||||
return invoice_vals
|
||||
Loading…
Reference in a new issue