← Back to team overview

openerp-connector-community team mailing list archive

Re: Sync Invoice to Magento

 

On 01/10/2014 12:10 PM, jan-philipp.fischer@xxxxxxxxxxxxxx wrote:
No, this change is light (most of the work is in the test):
 1. add the same selection field than the store's one on
payment.method (optional)
 2. changing the line where the option is used [0] to look in the
payment method's option, fall-backing to the store's one if empty
 3. add a test for that (already exist for the store's option)


Ok. I try to get better in programming OpenERP Modules. But I don't find
the codes for payment in branch. So I can't even start ;)
But I think it would be a great practice.
Or do you want to edit this? Or can we do it together?:)

I can guide you for this development. As I don't know at which point do you know the OpenERP development, let me know if you need more details.

The payment.method model is defined in the e-commerce-addons/sale_payment_method module, but I think this field should be defined only for the Magento connector (at least for now). So you need to extend this model with _inherit and the view in new files in the Magento connector to add the field.


Very interesting! Yes the connector only ask to create the invoice once.
If I understood right, Magento has internal methods to achieve that,
but does not propose public methods in the API? In such case, we could
add them to the PHP side of the connector (I don't have the knowledge
to do that), then we would be able to adapt the connector (OpenERP
side) to create once the invoice as "pending" and then mark it as paid
when paid in OpenERP. I can't represent myself how much changes it
need though.

Yes you understood it right. I have some knowledge on PHP and perhabs I
can handle that. So you can look at the OpenERP Part.

Nice to have someone with PHP skills in the community :-) I can indeed make the change in OpenERP as this is a more tricky than the first point. If we do that, seems to me that we'll be able to remove the "creation invoices on [validated/paid]" option, or do they still make sense?

I think that would be great for the connector because it's more
information for the customer and that's always good I think ;)
(Information if Invoice is created and when it is paid e.g. with emails
for the customer. Good to know if your money has arrived at company.)
That's true, by the way, there is another problem with the invoices: we can't change the invoice number in Magento so we can't make it match with the OpenERP one. This is a major point too (usually we hide the invoices from Magento due to that).


Greetings


Am 2014-01-10 11:15, schrieb Guewen Baconnier:
On 01/10/2014 10:48 AM, jan-philipp.fischer@xxxxxxxxxxxxxx wrote:
Thanks, glad to hear it worked for you. Yes, it could be possible to
have these options in the payment method. I would seriously consider a
merge proposal for this improvement.

This would be so great. I think this would be a nice improvement for the
connector. Do you think it's much work there?

No, this change is light (most of the work is in the test):
 1. add the same selection field than the store's one on
payment.method (optional)
 2. changing the line where the option is used [0] to look in the
payment method's option, fall-backing to the store's one if empty
 3. add a test for that (already exist for the store's option)


Ok, Magento is definitely very special in some ways ;-) This was the
rationale to create the invoice on Magento only when it was paid on
OpenERP and not when it was validated by default.

You're right. I also do not understand why magento doesn't manage that.
It's a huge piece of software but that isn't done ;)
I've done some research there:
- If you look in Magento Backend at the Invoice Tab you cann see that
you can filter with 'Pending', 'Paid' and 'Canceled' but you can't give
any of these other two Status to the Invoice. Strange!
- If you look here [0] you can see at 'sales_order_invoice.capture' that
you can check the invoice at different Status.
- This is done in 'Mage_Sales_Model_Order_Invoice' referring to this
page [1].
- And if you look here [2] at the posts of 'tzyganu' you can see that it
is easily possible to arrange that Magento can handle it. It's only
setting something to True.
I've tested it, and it worked. But the connector won't set it in Magento
to paid then. I think because the connector only syncs invoices once,
right?

So do you think it is possible to do that over API with
'Mage_Sales_Model_Order_Invoice'? I can imagine.

Very interesting! Yes the connector only ask to create the invoice once.
If I understood right, Magento has internal methods to achieve that,
but does not propose public methods in the API? In such case, we could
add them to the PHP side of the connector (I don't have the knowledge
to do that), then we would be able to adapt the connector (OpenERP
side) to create once the invoice as "pending" and then mark it as paid
when paid in OpenERP. I can't represent myself how much changes it
need though.


Many thanks for your translation!

You're welcome!:)

Jan

[0]: http://www.magentocommerce.com/wiki/doc/webservices-api/api
/sales_order_invoice
[1]: http://docs.magentocommerce.com/Mage_Sales
/Mage_Sales_Model_Order_Invoice.html
[2]: http://www.magentocommerce.com/boards/viewthread/54391/


Guewen

[0]
http://bazaar.launchpad.net/~openerp-connector-core-editors/openerp-connector-magento/7.0/view/head:/magentoerpconnect/invoice.py#L225



--
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/


References