corebos icon indicating copy to clipboard operation
corebos copied to clipboard

Multiple Companies or Brands

Open dfanaei opened this issue 2 years ago • 18 comments

Hi. I see there is a companies module. I am trying to create 2 different brands that will be under the same company but will need to show different information in the documents. for example, if I am sending the invoice to a client under brand 2, I want it to show the Brand 2 logo, website, email etc. How is this possible? What is the point of the "Companies" Module in general?

dfanaei avatar Jul 20 '22 05:07 dfanaei

The companies module was created for this purpose but the project hasn't evolved much. There aren't many users with this need, so, for the moment, it is just a starting point.

I would recommend you try adding a reference field to the company module in the invoice (for example) and then create the GenDoc template to access the information of the logo and address through that field instead of using the default company. That should permit you to automatically generate the correct output depending on the company that the invoice record is related to.

keep asking

joebordes avatar Jul 20 '22 08:07 joebordes

Thanks for the Reply @joebordes Connecting each invoice to a company is a lot of work and in the heat of the day it will be missed. Is there a way to connect the customer account to the brand/company and then have the document figure out the brand from the customer that is connected to the invoice?

dfanaei avatar Jul 28 '22 04:07 dfanaei

Also, Can you please let me know which special variable works to fetch the company logo? I tried these but none worked.

{image cbCompany.companylogo}

{image cbCompany.companylogo}

dfanaei avatar Jul 28 '22 06:07 dfanaei

Adding the company to the account and copying it to the invoice will work for sure. So you add a relation field on both the Account and the Invoice and then you fill in the company field in the invoice with the field from the Account. That will work. Getting the company from the Account in GenDoc should be possible also using the foreach directive

joebordes avatar Jul 28 '22 19:07 joebordes

ok sounds good @joebordes . I am still stuck trying to figure out how to get gendoc to grab the Company logo. I use the image directive but it's not working.

{image cbCompany.companylogo}

{image cbCompany.companylogo}

dfanaei avatar Jul 28 '22 20:07 dfanaei

Apply this change and then define the image as shown in this template: 44865_GenDocCompanyTemplate.odt

Let me know how it goes

joebordes avatar Jul 28 '22 22:07 joebordes

@joebordes It doesn't work. image Error when trying to open the generated doc.

and this is what the template looks like: image

dfanaei avatar Jul 29 '22 06:07 dfanaei

almost for sure there are formatting issues in some tags, that is a pain, but it is how it works. try using the debug output in the direct access to Generate Documents, see if that gives us some clue.

If you can share the template also I can give it a try

joebordes avatar Jul 29 '22 18:07 joebordes

Invoice_Template.odt

I don't think it is a formatting issue. Every time I use {image cbCompany.companylogo} the pdf doesn't ever open and it gives me the error.

dfanaei avatar Jul 29 '22 20:07 dfanaei

even trying to use the {ifexists} Directive, it doesn't work.

I am basically trying to tell it to show the logo A if the connected company is Company A and show logo B if the connected company is B.

{ifexists cbCompany=cmp-0000001} A {/ifexists} {ifexists cbCompany=cmp-0000002} B {/ifexists}

OR

{ifexists cbCompany.cbcompanyno=cmp-0000001} A {/ifexists} {ifexists cbCompany.cbcompanyno=cmp-0000004} B {/ifexists}

None of these work.

I am pretty much stuck figuring this out as none of the ways are working.

dfanaei avatar Jul 29 '22 21:07 dfanaei

The template I sent you uses Organization.companylogo not cbCompany. The special Organization entity captures the default cbCompany record. Can you try with that in your template?

That said, I suppose you have a uitype 10 field related to cbCompany in the Invoice which is the one you want to use for your template. Right? I did that and your template worked.

joebordes avatar Jul 30 '22 00:07 joebordes

ifexists directive is looking for related records in the related list, it just looks if a record with that condition exists in the given module, so if you actually have those two records in your coreBOS, cmp-0000001 and cmp-0000004, related to the record, both conditions will work always. But that would require a related list, not a uitype 10.

The syntax {ifexists cbCompany} checks for any related record The syntax {ifexists cbCompany.cbcompanyno=cmp-0000001} checks for a related record with that field value.

In short, this is not what you are looking for. Add the uitype 10

joebordes avatar Jul 30 '22 00:07 joebordes

Tried this:

{Organization.companylogo} {image Organization.companylogo} ACTUAL PICTURE

and it still doesn't work It comes out blank, the only thing that works is the first line and it only changes to the picture name (Text format).

dfanaei avatar Jul 30 '22 01:07 dfanaei

also, I definitly don't understand what you mean by uitype 10

dfanaei avatar Jul 30 '22 01:07 dfanaei

see if this helps: https://youtu.be/MrSZEia2Ftc

joebordes avatar Jul 30 '22 19:07 joebordes

pull before you try again, I left a debug message which breaks the output

joebordes avatar Jul 30 '22 21:07 joebordes

Thanks for the video @joebordes. I do everything based on your instructions. That last pull fixed the error. But the logo is still blank in the pdf. {cbCompany.companylogo} shows as "PICTURENAME.png" but

{image cbCompany.companylogo} IMAGE

is still shown blank.

I also tried creating a custom field for an image in the companies module and did both companies the same image size as the substitute image size. Refer to the SS Below

image

but this is what I get in the output:

image

dfanaei avatar Jul 30 '22 22:07 dfanaei

at this point, I can only offer a support ticket so we can connect to your installation and see what is happening. Contact me if you are interested.

joebordes avatar Jul 30 '22 23:07 joebordes