Merge lp:~akretion-team/openerp-connector/e-commerce-addons-payment-method-multicompany into lp:openerp-connector/7.0-e-commerce-addons

Proposed by arthru
Status: Merged
Merged at revision: 339
Proposed branch: lp:~akretion-team/openerp-connector/e-commerce-addons-payment-method-multicompany
Merge into: lp:openerp-connector/7.0-e-commerce-addons
Diff against target: 78 lines (+32/-4)
4 files modified
sale_payment_method/__openerp__.py (+1/-0)
sale_payment_method/payment_method.py (+17/-4)
sale_payment_method/payment_method_view.xml (+1/-0)
sale_payment_method/security/rules.xml (+13/-0)
To merge this branch: bzr merge lp:~akretion-team/openerp-connector/e-commerce-addons-payment-method-multicompany
Reviewer Review Type Date Requested Status
Guewen Baconnier @ Camptocamp Approve
Review via email: mp+190119@code.launchpad.net

Description of the change

This adds multicompany supports for payment methods.

Simply add a relation to a res.company from the payment.method, a field to configure it, and a security rule.

To post a comment you must log in.
Revision history for this message
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) wrote :

LGTM, thanks

review: Approve (code review)
Revision history for this message
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) wrote :

Can you propose the same change on the public e-commerce-addons branch please?
That's what I did myself too for the other addons than 'connector_ecommerce' (so when releasing, the MP will just concern connector_ecommerce).

Revision history for this message
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) wrote :

Hmm, sorry I approved too quickly.

Why is the company_id mandatory? Couldn't a payment method be shared between 2 companies?
Your rule considers that company_id may be empty.

review: Needs Information
Revision history for this message
Sébastien BEAU - http://www.akretion.com (sebastien.beau) wrote :

I think it's better to avoid to share payment method, because payment method are linked with a journal and the journal is specific to a company.
An other solution will be to have property field on payment method, but I think that not sharing payment method is simplier, what do you think?

339. By arthru

Remove of the required company for the payment method

Revision history for this message
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) wrote :

> I think it's better to avoid to share payment method, because payment method
> are linked with a journal and the journal is specific to a company.
> An other solution will be to have property field on payment method, but I
> think that not sharing payment method is simplier, what do you think?

Not necessarily, the journal_id is not mandatory.

Revision history for this message
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) wrote :

How the connectors do handle the selection of the correct payment method if two of them would be possible (1 per company)? Usually, the security rules would filter according to the user's company, but if sales orders are imported with the admin user, what happens?

review: Needs Information
Revision history for this message
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) wrote :

Thanks for the change.

I agree to merge it. The most important is to get it merged into the main branch though.

I'm still interested to know how you handle the selection of the correct payment method in the connectors if 2 methods have the same external id with a different company.

review: Approve
Revision history for this message
arthru (arthru) wrote :

As there is no payment method object in prestashop's API, we just match the payment method based on the name and on the company_id. So, there could not be 2 methods with the same external id, as there is no external id, juste a payment method name...

Revision history for this message
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) wrote :

On 11/15/2013 10:46 AM, arthru wrote:
> As there is no payment method object in prestashop's API, we just match the payment method based on the name and on the company_id. So, there could not be 2 methods with the same external id, as there is no external id, juste a payment method name...
>

Thanks for your answer.
What you are saying me is that the name of the method is your external
id. So, if you can have several methods with the same name but with a
different company_id, you have several external ids.

My question was more to know if you had implemented the support of
company_id in the Binder... But by reading your answer, I guess that not.

Please propose this merge on lp:e-commerce-addons/7.0

--
Guewen Baconnier
Business Solutions Software Developer

Camptocamp SA
PSE A, CH-1015 Lausanne
Phone: +41 21 619 10 39
Office: +41 21 619 10 10
http://www.camptocamp.com/

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'sale_payment_method/__openerp__.py'
2--- sale_payment_method/__openerp__.py 2013-03-28 17:08:45 +0000
3+++ sale_payment_method/__openerp__.py 2013-10-29 16:27:23 +0000
4@@ -43,6 +43,7 @@
5 'data': ['sale_view.xml',
6 'payment_method_view.xml',
7 'security/ir.model.access.csv',
8+ 'security/rules.xml',
9 ],
10 'demo': [],
11 'installable': True,
12
13=== modified file 'sale_payment_method/payment_method.py'
14--- sale_payment_method/payment_method.py 2013-04-03 07:33:59 +0000
15+++ sale_payment_method/payment_method.py 2013-10-29 16:27:23 +0000
16@@ -1,9 +1,9 @@
17 # -*- coding: utf-8 -*-
18 ###############################################################################
19 # #
20-# sale_quick_payment for OpenERP #
21-# Copyright (C) 2011 Akretion Sébastien BEAU <sebastien.beau@akretion.com> #
22-# Copyright 2013 Camptocamp SA (Guewen Baconnier)
23+# sale_quick_payment for OpenERP #
24+# Copyright (C) 2011 Akretion Sébastien BEAU <sebastien.beau@akretion.com> #
25+# Copyright 2013 Camptocamp SA (Guewen Baconnier) #
26 # #
27 # This program is free software: you can redistribute it and/or modify #
28 # it under the terms of the GNU Affero General Public License as #
29@@ -39,5 +39,18 @@
30 'payment_term_id': fields.many2one(
31 'account.payment.term',
32 'Payment Term',
33- help="Default payment term of a sale order using this method."),
34+ help="Default payment term of a sale order using this method."),
35+ 'company_id': fields.many2one(
36+ 'res.company',
37+ 'Company',
38+ ),
39+ }
40+
41+ def _default_company_id(self, cr, uid, context):
42+ company_model = self.pool.get('res.company')
43+ return company_model._company_default_get(cr, uid, 'payment.method',
44+ context=context)
45+
46+ _defaults = {
47+ 'company_id': _default_company_id,
48 }
49
50=== modified file 'sale_payment_method/payment_method_view.xml'
51--- sale_payment_method/payment_method_view.xml 2013-04-17 08:49:35 +0000
52+++ sale_payment_method/payment_method_view.xml 2013-10-29 16:27:23 +0000
53@@ -18,6 +18,7 @@
54 </h1>
55 <group name="general">
56 <group name="config">
57+ <field name="company_id" string="Company" />
58 <field name="journal_id" string="Journal for payment"/>
59 </group>
60 <group name="payment_help" class="oe_grey" col="1">
61
62=== added file 'sale_payment_method/security/rules.xml'
63--- sale_payment_method/security/rules.xml 1970-01-01 00:00:00 +0000
64+++ sale_payment_method/security/rules.xml 2013-10-29 16:27:23 +0000
65@@ -0,0 +1,13 @@
66+<?xml version="1.0" encoding="utf-8"?>
67+<openerp>
68+<data noupdate="1">
69+
70+ <record id="payment_method_rule" model="ir.rule">
71+ <field name="name">Payment method multi-company</field>
72+ <field name="model_id" ref="model_payment_method" />
73+ <field name="global" eval="True" />
74+ <field name="domain_force">['|','|',('company_id.child_ids','child_of',[user.company_id.id]),('company_id','child_of',[user.company_id.id]),('company_id','=',False)]</field>
75+ </record>
76+
77+</data>
78+</openerp>

Subscribers

People subscribed via source and target branches