I made some changes in the code of the module that adds availability to manage custom fields and manage displays of the Invoice entity.

Also all available fields are loaded from the referenced Order entity so you can use it on your Invoice display.

Please test it and review it works for you.

Comments

tomasbarej’s picture

Issue tags: +display suite, +fieldable
StatusFileSize
new4.61 KB

Here's the patch.

tomasbarej’s picture

Previous patch doesn't include new theme files so heres the fixed one.

c-logemann’s picture

Oh, that sounds very interesting. I will take a look at your patch as soon as I can.

c-logemann’s picture

Status: Needs review » Needs work

1. There are lot of these errors on field page (admin/commerce/config/invoice/fields) :
Notice: Undefined index: weight in _field_info_prepare_extra_fields() (line 429 of /var/www/commerce/web/modules/field/field.info.inc).

2. Where can an admin edit these fields? Even if you only think about field changes by code there should be a way to correct this.

tomasbarej’s picture

Status: Needs work » Needs review
StatusFileSize
new5.9 KB

1. There are lot of these errors on field page (admin/commerce/config/invoice/fields) :
Notice: Undefined index: weight in _field_info_prepare_extra_fields() (line 429 of /var/www/commerce/web/modules/field/field.info.inc).

Attached patch fixed this. There was missing one 'weight' index in field definition.

2. Where can an admin edit these fields? Even if you only think about field changes by code there should be a way to correct this.

Which fields you mean? The fields like Invoice ID and date of Creation are only on the Manage display tab where you can move it or hide it. Also all predefined and custom fields from Order entity is referenced in field display.

You mean that the Invoice ID and Creation fields should be also at Manage fields tab? I'm not sure if this is necessary if is not something that goes against Drupal entity logic. It's true that you can modify settings only of Invoice ID on the Invoice UI settings page (admin/commerce/config/invoice) so the Creation field is in some predefined format. We can decide where you should change the display of these two predefined fields.

marcoka’s picture

where exactly can fields be added? i searched for 10 minutes but can not find what exactly changed by this patch.

tomasbarej’s picture

When you properly clean caches after applying the patch you'll be able to set the fields on Invoice settings in Commerce store configuration (admin/commerce/config/invoice/fields).

The tabs Manage fields and Manage display should appear.

marcoka’s picture

ok i got.

after this patch, checkout doesnt work anymore:

DatabaseTransactionOutOfOrderException: in DatabaseConnection->rollback() (line 1049 of /mnt/www/WORKSPACE_DRUPAL/TESTPROJEKTE/drupal7_commerce/includes/database/database.inc).

edit: turns out i somehow shreddered my commerce :)

ps: is the patch against the dev?

tomasbarej’s picture

Yes, it's against dev branch.

I need to properly test the newly added custom fields to the invoice entity. My private goal with these changes was to make the display of existing fields easier to alter with for example Display Suite module.

marcoka’s picture

another problem that could be solved is the customization of the invoice, as a lot of people request that.

tomasbarej’s picture

If you mean customization of how the invoice is displayed you can definitely can with these fieldable changes since you can use for example Display Suite and its custom layouts to changing invoice display.

c-logemann’s picture

Title: Make invoice entity fieldable » Make invoice entity fieldable and themeable
Version: 7.x-1.0-alpha3 » 7.x-1.x-dev
Status: Needs review » Active

I didn't use commerce_invoice in this way but some people do and the feature is not problematic I think.
I checked the corrected patch and especially the theming is now working. So I committed it:
http://drupalcode.org/project/commerce_invoice.git/commit/a451bb8

@tomasbarej: But what about custom additional fields? Maybe if I add a textfield to the invoice entity (admin/commerce/config/invoice/fields).
Where can I modify the content of this field of a specified invoice? That was what I meant with my question 2 in comment #4.

c-logemann’s picture

@tomasbarej: Why did you removed $return = date('Y') . '-' . date('m') . '-' . $id;.
I didn't recognized but now it's back with last commit:
http://drupalcode.org/project/commerce_invoice.git/commit/2497d0e

tomasbarej’s picture

@C_Logemann: My first idea was to be able to manage the display of the entity using the Display Suite, that why I realize this fieldable patch. So I did not implement some form for that case when you want to edit some information in the invoice. Now, you're able to add additional information using rules or some custom code but there is no option to edit this information using Drupal backend.

@C_Logemann That was probably a mistake :)

c-logemann’s picture

Status: Active » Closed (fixed)

Yes theming including ds is helpful. When I think about it would be best to only use rules for inserting maybe text in a custom textfield before the customer is notified about the generated invoice. In my opinion invoices in a lawful meaning should not be modified. So in my shop I define the PDF I am generating with views and the help of commerce invoice as the real invoice not the entity this module is saving in the database.

So who ever wants more field modification can reopen this or open a new issue as feature request.

lefeed’s picture

Hi! Just a stupid question... I'm using the 7.x-1.x-dev and i'm trying(with no success!) to insert some text in a custom textfield using Rules. I mean:
1. I've added a "Company Name" textfield to the invoice from the Invoice UI
2. I've added a rule which reacts to the event "After saving a new commerce invoice"
3. When I choose "Add action" -> "Set a data value" my custom textfield "Company Name" doesn't show up in the Data selectors list.
What am I missing?